Reputation: 28284
I have multiple clients that I have subdomains for client1.example.com client2.example.com ... etc etc
now in my root directory I have one common code base and rest is different depending on clients
so in my root directory I have these folders mymainrepo client1 client2
mymainrepo contains all the common code
client1 contains multiple folders like cache dbsettings client2 contains multiple folders like cache dbsettings
But the content of cache and dbsettings is different for every client. so what I want to do is if a request comes in for a client and it asks for a cache folder contenet, i want it to be served form that clients folder
so if a request is client1.example.com/cache it will serve the contents from
doc root
|
|
-------client1
|
|_______cache
and if the request is client2.example.com/cache it will serve from
doc root
|
|
-------client2
|
|_______cache
and so on and so on.
Any help will be appreciated thanks
** EDITED **
ok so I tried this and this sorta works
RewriteEngine on
RewriteCond %{HTTP_HOST} ^((?!www\.).+)\.domain.com$[nc]
RewriteRule ^(.*)$ %{HTTP_HOST}/$1 [r=301,nc]
DirectoryIndex client1/index.html
problem is I want to have this dynamic instead of client1 hard coded
DirectoryIndex client1/index.html
I tried
DirectoryIndex %1/index.html
but that did not work
any help will be appreciated
Upvotes: 2
Views: 238
Reputation: 41219
You can use something like the following
RewriteEngine on
RewriteCond %{HTTP_HOST} ^((?!www\.).+)\.domain.com$
RewriteRule ^.*$ /%1%{REQUEST_URI} [L]
This will rewrite client.domain.com/path
to the /client
folder of your main document root. So if the request is client.domain.com/cache
this will internally redirect it to /client/cache
showing you the contents from that folder.
Upvotes: 1