I don't know about .htaccess
file but I'm pretty sure this would work:
RewriteEngine On
RewriteCond %{HTTP_HOST} customer([0-9]+)\.com
RewriteRule ^/app/(.*) /app/customers/customer%1/$1 [QSA]
Explanation:
RewriteCond %{HTTP_HOST} customer([0-9]+)\.com
will put in the variable '%1
' the customer number i.e. '1
'
RewriteRule ^/app/(.*) /app/customers/customer%1/$1 [QSA]
Means: if the path begins with '/app/
' then rewrite it to /app/customers/customer
and add the variable '%1
' (i.e. '1
' in our example) so it should work with what you're asking for: rewrite to http://customer1.com/app/customers/customer1/
.
I'm sorry but your question is not really precise, and you should either giver more examples, or be more specific to what you want to do, but I did my best to help you.
You may use the RewriteMap
directive as well.
Imagine you put all your clients websites and the right directories in it like this:
alsace 1
aquitaine 2
auvergne 3
basse-normandie 4
bourgogne 5
bretagne 6
centre 7
champagne-ardenne 8
corse 9
franche-comte 10
haute-normandie 11
then I use a RewriteRule like this:
RewriteMap mapregions dbm:/web/htdocs/maps/regions.map
RewriteRule ^/region/(.*)/$ /handle_regions.php \
[NC,E=REGION:${mapregions:$1|notfound}]
So what it does is basically: if you ask for an url like /region/(.*)/
it redirects to /handle_regions.php
and sets an environment variable REGION
Then I just check if it was found: if not, I stop:
RewriteCond %{ENV:REGION} notfound
# "not found" = 404 :
RewriteRule .* - [R=404,L]
And then here you are. I'm sorry but with all the things I've just said, you have enough material to solve your problem. I don't have the time to do all the stuff for you, sorry man, I did the best I could to help you... and I hope this helps!
/data/www/cms/app/customers/foo.com/assets/css/bg.png
with foo**.com** or only "foo" without the ".com" (= is this a mistake or not)? This is important for the rewrite rule I may answer.