Q:

Apache Rewrite doesn't work to turn any domain name into a .com domain from a .co.uk one

I am using the following rule to turn any domain name into a .com domain from a .co.uk one. Why doesn't this work? Do people have a better way of doing this?
<IfModule mod_rewrite.c>
    RewriteCond %{HTTP_HOST} ^(.*).co.uk(.*)$ [NC]
    RewriteRule $1.com$2 [R=301,L]
</IfModule>

A:

Your rewrite rules's syntax is wrong. This is the code that should work for you:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(.+?)\.co\.uk$ [NC]
RewriteRule ^ http://%1.com%{REQUEST_URI} [R=302,L]

Once you verify it is working fine, replace R=302 to R=301. Avoid using R=301 (Permanent Redirect) while testing your mod_rewrite rules.

