.htaccess Remove WWW from URL + Directories

I had the same problem (trouble stripping ‘www’ from URLs that point to a sub-directory on an add-on domain), but after some trial and error, this seems to work for me:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]

Leave a Comment