What I am trying to do is automatically redirect the domain for one of my sites
www.domain1.com
to www.domain2.co.uk
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain1.com\. [NC]
RewriteRule (.*) http://%www.domain2.com\%{REQUEST_URI} [R=301,NC,L]
I have looked over the site for the answer and the above is my code that I edited from another answer, but it doesn't work.
I would like it in a .htaccess file - is this the best way of doing it?
Thanks
URL redirect (URL forwarding) allows you to forward your domain visitors to any URL of your choice (to a new domain or a different website). You can set 301 (Permanent), 302 (Unmasked), and Masked (URL Frame) redirects for the domain names pointed to BasicDNS, PremiumDNS or FreeDNS.
To redirect from www.domain1.com
to www.domain2.co.uk
, you may try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com [NC]
RewriteRule ^(.*)$ http://www.domain2.co.uk/$1 [R=301,NC,L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With