.htaccess redirect question

Soldato
Joined
18 Oct 2002
Posts
4,205
Location
West Lancashire
Hi,

I've registered a .com and .co.uk with the same name and want to redirect the .com to the .co.uk

Is the following correct?

Code:
Redirect PERMANENT http://www.mydomain.com/ http://www.mydomain.co.uk/

How would that behave if someone tried mydomain.com/mta.php, would it forward to mydomain.co.uk/mta.php or just to mydomain.co.uk/ ?

Hope that makes sense :confused:
 
That would just take everything too yourdomain.co.uk. Try this.

Code:
RewriteEngine On

RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
RewriteRule ^.*$ http://www.yourdomain.co.uk%{REQUEST_URI} [R=permanent,L]

This will only work if your host supports mod_rewrite though. Most do these days.
 
Last edited:
Back
Top Bottom