http 301 redirection issue
Posted
by
Guilhem Soulas
on Server Fault
See other posts from Server Fault
or by Guilhem Soulas
Published on 2012-09-04T12:45:16Z
Indexed on
2012/09/04
15:42 UTC
Read the original article
Hit count: 182
I'm a little bit lost with a redirection.
I want mysite.com, www.mysite.com and www.mysite.co.uk to redirect to mysite.co.uk.
In Apache, I wrote this for mysite.co.uk in order to redirect www to the root domain:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www
RewriteRule ^/(.*) http://mysite.co.uk/$1 [L,R=301]
And for mysite.com, I wrote this redirect to mysite.co.uk:
ServerName www.mysite.com
RewriteEngine on
RewriteRule ^/(.*) http://mysite.co.uk/$1 [L,R=301]
This way, I can make the redirection work properly from www.mysite.com to mysite.co.uk, but it doesn't work for mysite.com too mysite.co.uk (without the www) at the same time. Could someone tell me how to make all my redirections work in all cases?
© Server Fault or respective owner