Knowledgebase: Hosting FAQ > Tips and Tricks
Force visitors coming in to domain.com or via aliases to use www.domain.com
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} !^www.domain.com$ [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]


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


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} !^domain.hostasaurus.com$ [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]

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

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
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 support.miva.com/supportsuite/index.php?