Skip to content

How to redirect one domain to other domain with all query string variables (htaccess)

If you ever have the need to move domain names, the following .htaccess code will help move all visitors to your second domain name. This method also preserves your URLs’ query string variables, so there’s a less likely chance of something breaking.

You can use this:

RewriteEngine On
RewriteCond %{HTTP_HOST} firstdomain.com$
RewriteRule ^(.*)$ http://www.seconddomain.net/$1 [L,R=301]

1 thought on “How to redirect one domain to other domain with all query string variables (htaccess)”

Leave a Reply

Your email address will not be published. Required fields are marked *