Forum Moderators: phranque

Message Too Old, No Replies

Redirect to new domain, keep abc.html

Trying to redirect www.olddomain.com/abc.html to www.newdomain.com/abc.html

         

halijan

5:42 am on Jun 3, 2009 (gmt 0)

10+ Year Member



Hi Guys,
i'm after some help and struggling to find an answer through websearching, but im trying to work this into my .htaccess:

Redirect [olddomain.com...] to [newdomain.com...]

We currently have an old domain and a new domain that serve off the same folder. I'm looking for the old domain to redirect to the new domain, but keep the /yxz/acb.html or whatever file/folder it may be.

Any help would be greatly appreciated,

Cheers

g1smd

8:18 am on Jun 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



On the left, the pattern to match the path part of the URL. On the right, the domain name and path you are redirecting to:

RewriteEngine On
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

There's a couple of thousand prior examples in the forum. It's well worth reading old threads. Many explain why something is done a particular way too.

halijan

11:21 pm on Jun 4, 2009 (gmt 0)

10+ Year Member



Hello,
thank you for your reply and sorry for my poor understanding of rewriting.

Upon using the above code, i received the following error when trying to access the page, through both the olddomain and the newdomain addresses:

"Too many redirects occurred trying to open “http://www.newdomain.com/”

I'll have a dig around some old threads but would appreciate any help in the mean time.

Thanks

g1smd

11:46 pm on Jun 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That's an Infinite loop, redirecting to itself.

Precede the Rule with:

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]

I missed that line out in error yesterday.