Remove www From URL using .htaccess in Apache
Tagged with: apache, Code, htaccess, mod_rewrite, remove, www
This htaccess code will remove the ‘www’ part from the url. It uses the mod_rewrite module of apache to re-write the url - so make sure that’s installed.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
September 10th, 2008 21:22
[...] Remove www From URL using .htaccess in Apache [...]
October 10th, 2008 06:12
Thanks you for this helpful code… WordPress was killing me, sometimes it worked, sometimes not, until I found out, that it depended on the written url: with www bad (header already send error), without fine, so your code was exactly what fixed my prob ^^