This is a discussion on How to use mod_rewrite to change DocumentRoot by client IP like condition within the Apache Web Server forums, part of the Web Server and Related Forums category; Hello, First, I do not speak english very well, I'm brazilin, I'm sorry. I did try on a ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
First, I do not speak english very well, I'm brazilin, I'm sorry. I did try on a group "Apache Brasil" before, but didn't receive any kind of answer. I tried to look on Google for this issue extensely before too, I didn't understand what I found, maybe answer was found. It seems very trivial and I think you can help me easily. I want to make a rule using mod_rewrite which can modify "DocumentRoot" option defined on httpd.conf, using client IP for the condition, something like that: >From 192.168.1.1 "DocumentRoot" = "/var/www/01" >From 192.168.0.2 "DocumentRoot" = "/var/www/02" Or: >From 192.168.1.1 "DocumentRoot" = "/var/www/01" Else "DocumentRoot" = "/var/www/02" Thank you very much. Best regards, |
|
|||
|
lmaxcar wrote:
>>From 192.168.1.1 "DocumentRoot" = "/var/www/01" > Else "DocumentRoot" = "/var/www/02" Set (in your httpd.conf/<virtualhost>, if you're using one) DocumentRoot /var/www/02 And use mod_rewrite to rewrite one specific IP, also in your httpd.conf/<virtualhost> RewriteEngine on # check the IP address - it should be available in th env # REMOTE_ADDR (note: this is not a RegEx, so don't escape # the periods here RewriteCond %{REMOTE_ADDR} =192.168.1.1 RewriteRule ^/(.*) /var/www/01/$1 [L] -- Robert |