How to use mod_rewrite to change DocumentRoot by client IP like condition

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 ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-19-2006
lmaxcar
 
Posts: n/a
Default How to use mod_rewrite to change DocumentRoot by client IP like condition

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,

  #2 (permalink)  
Old 03-19-2006
Robert Ionescu
 
Posts: n/a
Default Re: How to use mod_rewrite to change DocumentRoot by client IP likecondition

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:38 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0