DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Marco has posted 3 posts at DZone. View Full User Profile

Add Www In Front Of Domain Name

07.27.2006
| 7050 views |
  • submit to reddit
        Add 'www' in front of the domain name through .htaccess file.

For example http://yoursite.com will automatically redirect to http://www.yoursite.com

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursite\.com
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=permanent,L]