AlexB
AlexB

Reputation: 2184

redirecting request from any tld to .com version

need some solution here with redirecting all of my domain (a.e mysite.co.uk, mysite.org etc) to the .com version.

My .htaccess contains the following code:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /

 RewriteCond %{HTTPS} on [OR]
 RewriteCond %{HTTP:X-Forwarded-Proto} https [OR]
 RewriteCond %{SERVER_PORT} ^443$
 RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-l
 RewriteRule ^(.*)$ index.php/$1 [QSA,L,NC]

</IfModule>

Please help me out here

Thanks in advance

Upvotes: 0

Views: 22

Answers (1)

AlexB
AlexB

Reputation: 2184

Nevermind, I think I have just found the solution:

I have added the following lines to my .htaccess

RewriteCond %{HTTP_HOST} !^(www\.)mysite\.net$ [NC]
 RewriteRule ^(.*)$ http://www.mysite.net/$1 [L,R=301]

I hope this is correct way of doing this?

Upvotes: 1

Related Questions