Knowledgebase: Hosting FAQ > Tips and Tricks
Force visitors coming in to or via aliases to use
Posted by Jen Ferraz on 11 April 2011 02:37 PM
If people are coming into your site using just the domain name without the www, and you need to have them using www, the following code placed in a .htaccess file in your httpdocs/ directory will fix the problem. This can also be used to 301 redirect aliases domains to the primary domain name.

Please modify the domain to match your own.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*)$1 [L,R=301]

If you are a former Hostasaurus customer and are using a shared SSL certificate on your site, which always takes the form where "domain" is your domain, then you must use this set of rules instead:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*)$1 [L,R=301]

(3 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below. This is required to prevent automated registrations and form submissions.

Help Desk Software by Kayako