I currently have the following in a htaccess file which redirects certain requests to the requested domain's individual folder if the file does not exist in the root..
RewriteRule ^contact/?$ ASSETS/%{HTTP_HOST}/contact.php
RewriteCond %{REQUEST_URI} !^/ASSETS/%{HTTP_HOST}/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /ASSETS/%{HTTP_HOST}/$1
RewriteCond %{HTTP_HOST} ^(www.)?%{HTTP_HOST}$
RewriteRule ^(/)?$ ASSETS/%{HTTP_HOST}/index.php [L]
Which works fine when my domain folders are named like /ASSETS/www.domain1.com, /ASSETS/www.domain2.com etc
However, I've built a lot of my code already with the assumption that the folders will be labeled /ASSETS/domain1.com etc (domain name, minus the www.)
I'm thinking there is a way to get the domain name from %{HTTP_HOST} into a new variable and strip out the www. part (like an str_replace or something), but all the answers I have found are around a basic redirect all to www. or no www. which isn't going to work as I still want users to access the site from the forced www. version.
I was previously running the rules for each domain individually with a RewriteCond %{HTTP_HOST} ^(www.)?domain1.com$ but there are so many domains now, it's not feasible to do it for each one.
Hope you can help! Thanks in advance.