All about building and managing your website
How to remove www from a domain
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 quick test and make sure everything works properly.
| Print article | This entry was posted by admin on March 18, 2010 at 12:52 pm, and is filed under Server Configuration. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |
Comments are closed.