I have a list of domains that all point to the same IP Address and I want to be able to dynamically rewrite the url to go to a folder based on the domain name.
For example, I want coolsite.com/blah.php
to point to /coolsite/blah.php
.
I have the following in my .htaccess file, but it doesn't work
#Capture the domain without the 'www' or '.com'
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)\.com
#if the request hasn't been rewritten to the new folder
RewriteCond %{REQUEST_URI} !^/%1
#Rewrite request so that it inserts that folder in the path
RewriteRule ^(.*)$ /%1/$1 [L]
I know I can just make a bunch of VirtualHost
s in my httpd.conf, but there are a ton of domains that I'm using.
Is it even possible to do this with mod_rewrite?