.htaccess domain re-direct

Discussion in 'Apache' started by dropandhop, Nov 12, 2007.

  1. #1
    Hi all,

    Hope that you can help.

    I would like to re-direct www.olddomain.com and all of its files and subdirectories (like www.olddomain.com/test.html) to the index of www.newdomain.com

    I tried to use the following code:
    Redirect 301 / http://www.newdomain.com/

    It worked great when I hit www.olddomain.com but when I tried to hit www.olddomain.com/test.html it tried to bring me over to www.newdomain.com/test.html not to the index file of the newdomain.com (not what I wanted it to do as it won't work b/c that file doesn't exist anymore).

    I would appreciate any help you can offer.

    Thanks again!
    A
     
    dropandhop, Nov 12, 2007 IP
  2. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    I would try this:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.oldomain.com$ 
    RewriteRule ^(.*)   http://www.newdomain.com/  [L,R=301]
    
    Code (markup):
    Jean-Luc
     
    Jean-Luc, Nov 12, 2007 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    Nintendo, Nov 12, 2007 IP
  4. dropandhop

    dropandhop Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi Jean-Luc,

    Thanks for your reply!

    Unfortunately that didn't seem to work. With that .htaccess file in place it didn't re-direct at all (when going to both www.olddomain.com and www.olddomain.com/test.html)

    Any other ideas?

    Thanks again,
    A
     
    dropandhop, Nov 12, 2007 IP
  5. dropandhop

    dropandhop Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Nintendo,

    Thanks a ton...that seemed to do a trick!

    Now, my question for you is, do I loose loose page ranks with this method? I thought that using a 301 was the best way to go so that you don't loose page ranks.

    Any thoughts?

    Thanks!
    A
     
    dropandhop, Nov 12, 2007 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    PR will probably go to the new page.
     
    Nintendo, Nov 12, 2007 IP
  7. dropandhop

    dropandhop Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I am trying to do one more simple redirect, while keeping my existing redirect intact.

    While still redirecting to the newdomain (as per below) I would like to make an exception and redirect one specific file as such:
    www.olddomaincom/pdf/notes.pdf
    to
    www.newdomaincom/images/stories/notes.pdf

    Below is what I am currently using.

    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REMOTE_HOST} !^ipaddress\.ipaddress\.ipaddress\.ipaddress
    RewriteRule ^(.*)$ http://www.newdomain.com/ [R=301,L]

    Thanks again for any help you can provide, I just can't seem to get it!
     
    dropandhop, Dec 3, 2007 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    Nintendo, Dec 4, 2007 IP