httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean T Allen <s...@usaherbals.com>
Subject Re: [users@httpd] Apache config directives based on requestor ip address?
Date Fri, 10 Dec 2004 22:37:10 GMT
mod_rewrite is what you want...

you can accomplish what you want...

For example

RewriteCond %{REMOTE_HOST} 192.1.1.1
RewriteRule (.*) /alt-root/$1
RewriteCond %{REMOTE_HOST} !192.1.1.1
RewriteRule /alt-root/(.*) /reg-root/$1

And both can exist under the regualr document root

so any access to alt-root from somewhere other than 192.1.1.1
gets sent to reg-root ( security )
and any 192.1.1.1 looks in alt-root instead...

you get the basic idea... it needs a bit of tweaking...

OR...

you can filter yourself with c code using the apache api
or you can install a perl handler via mod-perl

but really the mod_rewrite is the easiest way to go.


Andrew Boyce-Lewis wrote:

>>>From what I have read, mod_rewrite will allow me to change the URL based
>on %{REMOTE_HOST}, however what I want to do is change is the
>DocumentRoot based on the remote host
>
>...so that the URL would still be http://example.com, but the root that
>was being displayed would be different if I was coming from a specific
>host. Is this possible?
>
> -Andrew
>
>
>
>On Fri, 2004-12-10 at 12:30, Sean T Allen wrote:
>  
>
>>mod_rewrite can be used to accomplish what you want in spirit if not in 
>>the design you
>>have below.
>>
>>
>>Andrew Boyce-Lewis wrote:
>>
>>    
>>
>>>I am looking for a way to apply alternative configuration directives to
>>>apache based on the source ip address. Basically, I was to do something
>>>like this:
>>>
>>><VirtualHost *>
>>>       ServerName test.example.com
>>>	<RequesterMatch 10.0.0.42>
>>>		DocumentRoot /var/web/root/a
>>>	<RequesterMatch>
>>>	<RequesterMatch !10.0.0.42>
>>>		DocumentRoot /var/web/root/b
>>>	<RequesterMatch>
>>></VirtualHost>
>>>
>>>Obviously the RequesterMatch directive does not exist. Has anyone solved
>>>this problem in the past? I can think of a number of somewhat ugly ways
>>>to solve this problem using iptables, but an elegant solution would be
>>>best. 
>>>
>>>Any ideas and/or experience with such problems?
>>>
>>>Thanks,
>>>	-Andrew
>>>
>>> 
>>>
>>>      
>>>
>>______________________________________________________________________
>>---------------------------------------------------------------------
>>The official User-To-User support forum of the Apache HTTP Server Project.
>>See <URL:http://httpd.apache.org/userslist.html> for more info.
>>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>>For additional commands, e-mail: users-help@httpd.apache.org
>>    
>>


Mime
View raw message