mod_rewrite remove www for all domains

446 Views Asked by At

I have multiple domains all pointing to the same website and depending on which domain you enter the website, will determine which categories will be selected.

For this to work I have to place any Mod_Rewrite code inside my apache2/sites-available/primarydomain file.

The website has the potential to host hundreds of domains so I need a system where I dont have to write a rule out for each domain eventuality.

I have seen this suggested online

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

but it doesnt work for me.

Does any regex guru out there know if this is even achievable?

Heres hoping :-)

0

There are 0 best solutions below