Support » Knowledge Base » Shop-Script » Tips & Instructions »
If you have module mod_rewrite set up and enabled on your server, then you may use special directives in your .htaccess file in order to automatically redirect website visitors to another domain name. Below are offered several examples of such redirecting rules. To use them, add the code of the appropriate example at the beginning of your .htaccess file located in the root directory of your domain name on the web-hosting server.
RewriteEngine On
RewriteCond %{HTTP_HOST} domain1.com
RewriteRule (.*) http://domain2.com/$1 [R=301,L]
Instead of the www subdomain you can set up redirecting to any other subdomain in a similar fashion; e.g., from domain.com to shop.domain.com.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www.) [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Instead of the www subdomain you can set up redirecting from any other subdomain in a similar fashion; e.g., from shop.domain.com to domain.com.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Note that the above rules will redirect website visitors to the specified domain name with URL parameters preserved. The URL parameters are the part of the web page address (URL) which follows the website's domain name. E.g., in a URL of the form
Tip 1: If you do not want URL parameters to be preserved, remove $1 from line 3.
Tip 2: If you want another website to be displayed without visitors being redirected to that website, change the contents in square brackets in line 3 from [R=301,L] to [L].