Return to Snippet

Revision: 4689
at January 16, 2008 03:04 by torkil


Initial Code
# force removal of www IN URL
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
# END force removal of www IN URL# force www IN URL

Initial URL
http://www.torkiljohnsen.com/2008/01/16/some-easy-use-of-mod_rewrite/

Initial Description
Using mod_rewrite in Apache to rewrite urls and force removal of www in urls. Good for letting search engine spiders in the right door...

Insert the code in your .htaccess-file in your website's root folder.

Initial Title
Force removal of WWW in url

Initial Tags
url, htaccess, apache

Initial Language
Apache