I have an Apache webserver behind a load balancer which proxies request to Apache and have problem regarding configuring directories.
Here is my scenario:
- Upper Load Balancer proxies request to Apache with adding original Hostname in
X-Forwarded-Host
. - I should decide which directory to serve based on
X-Forwarded-Host
header value. - Incoming requests have
X-Forwarded-Host
headers like:
test1.example.com
test2.example.com
test3.example.com
- Here is my desired behavior:
Each request must be served from:
%{DocumentRoot}/test1/
%{DocumentRoot}/test2/
%{DocumentRoot}/test3/
- I wrote something like this, but it needs to be corrected:
RewriteCond "%{HTTP:X-Forwarded-Host}" "^[^.]*"
RewriteRule "^(.*)" "%{DOCUMENT_ROOT}/%1/$1" [L]
Any help on how to write Rewrite Rule?