All about building and managing your website
Posts tagged add www to domain
How to remove www from a domain
Mar 18th
Want an easy way to make sure your visitors always see http://yourdomain.com instead of http://www.yourdomain.com? Here’s how to automatically remove the www from your domain (or vice versa).
First, edit (or create) your .htaccess file, using mod_rewrite to either remove the www from, or add it to your domain.
To remove the www from your domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} www.example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
To add the www to your domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Next, simply upload your .htaccess file to the root directory of your web server and you should be all set. Be sure to give it a More >