Is it possible to use .htaccess file to rewrite this:
http://customer1.com/app/assets/css
into this:
http://customer1.com/app/customers/customer1/assets/css?
If it is then how?
EDIT: The goal is to avoid any updates to .htaccess when a new customer is added EDIT2:
I see that my question has been too vague. I have a CMS that is being used for lots of different customers (www.foo.com, www.bar.com, www.somerandomname.com). Each customer has it's unique files (design, uploads) in a directory /data/www/cms/customers/XXXXXX/ where XXXXXX is the name of the customer. Apache config file has default DocumentRoot set on /data/www/cms/.
What I'm trying to do is to have the URL http://www.foo.com/app/assets/css/bg.png to return a file from the given customers data directory, i.e. /data/www/cms/app/customers/foo.com/assets/css/bg.png.
I don't know about
.htaccess
file but I'm pretty sure this would work:Explanation:
will put in the variable '
%1
' the customer number i.e. '1
'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 tohttp://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:then I use a RewriteRule like this:
So what it does is basically: if you ask for an url like
/region/(.*)/
it redirects to/handle_regions.php
and sets an environment variableREGION
Then I just check if it was found: if not, I stop: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!
That will be something like: