24Dec/090
remove www from url with mod_rewrite
An important topic of SEO is avoiding "double content" in your website. and the first thing to do about it, is to 301 redirect the URLs with www to URLs without www or vice versa.
Because search engines determine URLs with www as a subdomain and index it separately.
How to do this?
We can use Apache's mod_rewrite.
First of all you should create a file named ".htaccess" in your website and then :
To remove www from URLs add this lines to the file :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yoursiteurl.com$ [NC]
RewriteRule ^(.*)$ http://yoursiteurl.com/$1 [R=301,L]
Adding www to URLs instead of removing it :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursiteurl.com$
RewriteRule (.*) http://www.yoursiteurl.com$1 [R=301]