The following set of rewrite rules rewrite any URLs formatted as http://foo.example.com/bar
to http://example.com/mysubs/foo/bar.php
. This all works fine except if I have a subdirectory named 'blah' in the original URL such as http://foo.mydomain.com/blah/bar
, then it will rewrite it as http://example.com/mysubs/foo/bar
(without the blah subdirectory) when what I need is the url to be rewritten as http://example.com/mysubs/foo/blah/bar
.
So, what do I need to change to make this work correctly?
Options +FollowSymLinks
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !www.example.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^./]+)\.example\.com$
RewriteRule !^mysubs/ mysubs/%1%{REQUEST_URI} [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php