Manage www with .htaccess


May 17th, 2008

For your domain if you require www you can achieve this by adding the following code in your .htaccess file:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ /$1 [R=301,L]

Now, what if you don’t require www, add this code in your .htaccess:

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

Try it.

This article is released by SupportFacility.Com — the leaders in providing outsourced technical support, live chat support & help desk support for web hosts. Interested ? Opt for a trial now.


No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment