301 redirect old domain to new domain using .htaccess

Discussion in 'Apache' started by electronicbrush, Sep 24, 2007.

  1. #1
    I have a site (olddomain.com) and i'm planning to redirect it and all its pages to newdomain.com keeping the same folder structure, so that when someone clicks on olddomain.com/company/sample/ it will redirect them to
    newdomain.com/company/sample/ I tried using the following code in my .htaccess but it always redirect me to the homepage of the newdomain.com:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://newdomain.com/$1 [R=301,L]

    What am i missing here?

    Thanks for the help
     
    electronicbrush, Sep 24, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    RewriteBase /
     
    Nintendo, Sep 24, 2007 IP
  3. electronicbrush

    electronicbrush Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Nintendo, so you say it has to be something like this:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule (.*) http://newdomain.com/$1 [R=301,L]
     
    electronicbrush, Sep 24, 2007 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    Yep.

    If you've never used mod_rewrite on your site, you can also try taking out

    Options +FollowSymLinks
     
    Nintendo, Sep 24, 2007 IP
  5. electronicbrush

    electronicbrush Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks Nintendo it worked nicely
     
    electronicbrush, Sep 25, 2007 IP