Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Banned
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .htaccess redirect infinite loop

    Hi guys,

    I'm completely new to apache and trying to 301 redirect a domain to another domain. I used .htaccess with

    Options +FollowSymLinks

    RewriteEngine on

    RewriteRule (.*) http://www.new-domain.com/$1 [R=301,L]


    It created an infinite redirect loop. Then I tried if I could do it page by page:

    redirect 301 /page.html http://www.newdomain.com/page.html


    The problem seems to be that www.olddomain.com and www.newdomain.com point to the same directory on the server. Request to old domain redirects to new domain, but then reads the same .htaccess file again and and again... Doh

    Could anybody help, is there a way around this?

    Thanks a million !

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,479
    Thanks
    6
    Thanked 981 Times in 954 Posts
    Then try making it
    Code:
    RewriteRule !^new-domain.com$ http://www.new-domain.com/$1 [R=301,L]
    or
    Code:
    RewriteCond %{HTTP_HOST} !^new-domain.com$ [NC]
    RewriteRule ^(.*)$ http://new-domain.com/$1 [L,R=301]
    That also gets rid of the www/no-www duplicate content issue.

  • #3
    Banned
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by VIPStephan View Post
    Then try making it

    Code:
    RewriteCond %{HTTP_HOST} !^new-domain.com$ [NC]
    RewriteRule ^(.*)$ http://new-domain.com/$1 [L,R=301]
    Fantastic. Brilliant. Chuffed.

    Thank you so much!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •