Tag Archives: URL Parameters

Domain Redirection via .htaccess while keeping other url parameters.

Lets say if you want to redirect your visitors from  http://www.domainA.com/?p=667 to http://www.domainB.com/?p=667

you can achive this via adding following code to your .htaccess file.

Options +FollowSymlinks -MultiViews
RewriteEngine on

# for http
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ http://www.domainB.com/$1 [R=301,L]

# for https
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteCond %{SERVER_PORT} =443
RewriteRule ^(.*)$ https://www.domainB.com/$1 [R=301,L]

Reference : http://stackoverflow.com/questions/5956844/how-to-redirect-a-url-by-only-changing-the-domain-name-while-keeping-other-url?rq=1