PDA

View Full Version : apache rewrite redirect - just will not work



Morgenmuffel
14-06-2011, 08:16 PM
Ok I have to write redirects on 2 servers

there are 3 domains
the site was formerly hosted under example.com
and is now being moved to a different server using the name example.com.au
example2.com is another name variant pointed at the server

I need to have a redirect on the old server (its should be disappearing in 48 hours but until then)

This doesn't work (on the old server)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$[OR]
RewriteCond %{HTTP_HOST} ^example2.com$
RewriteRule ^(.*)$ http://example.com.au/$1 [R=301,L]

so I am currently using this rule
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$
#RewriteCond %{HTTP_HOST} ^example2.com$
RewriteRule ^(.*)$ http://example.com.au/$1 [R=301,L]

But I do want to redirect both domains to the new host

on the new server I have the following rule

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$
#RewriteCond %{HTTP_HOST} ^example2.com$
RewriteRule ^(.*)$ http://example.com.au/$1 [R=301,L]

Now obviously i am having the same problem as the old server regarding redirection both domains.
BUT I am also worried that I may create a loop
would example.com.au be hit by this line
RewriteCond %{HTTP_HOST} ^example.com$

and end up creating a loop?

inphinity
14-06-2011, 08:21 PM
Why are you redirecting anything at all from the new server?

Morgenmuffel
14-06-2011, 08:36 PM
Why are you redirecting anything at all from the new server?

I am not trying to redirect from the new server, but the old domains will eventually be pointed at it (once the old server is turned off) and they are indexed in google

so if somethings coming in to the new server as

example2.com/bugs.com
or
example.com/bugs.com

I want it to redirect to

example.com.au/bugs.com