|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
client ip based redirecting
Hi gurus!
i'm just wondering if there is a way to redirect a client (or better set the DocumentRoot) based on his ip address. for example: --------------------------------------------- client ip: 127.0.0.1 DocumentRoot: d:/httpd_pub --------------------------------------------- client ip: 10.150.0.22 DocumentRoot: d:/httpd_pub/users --------------------------------------------- any idea? Thanks in advance! |
|
#2
|
|||
|
|||
|
You can't really set docroot on-the-fly but you can use some kind of authentication along with Satisfy directive so client coming from 10.150.0.22 to d:/httpd_pub/users can bypass the authentication.
|
|
#3
|
||||
|
||||
|
mmmh....that's not what i really want.
i'll explain better: if a user is accessing from localhost, he can view all the server root ("http://my_server"). but...if coming from an external ip, such as 10.150.0.22, i want to redirect him to a subdir (like "http://my_server/users"), without access to the root. Hope this is possible ![]() |
|
#4
|
|||
|
|||
|
>> that's not what i really want
I know what you want but I gave you another suggestion instead because your way of redirecton implementation is just lame and inefficient. Why? Because silly things like this should not be done entirely on the server side. Further, you can use vhost so you can have http://my_server.domain.com and http://user.domain.com. People who want to go to user.domain.com just type that in URL, that's all. Redirecting to a subdir is really outdated and should not be used any longer. >> Hope this is possible Of course it's possible. But to do it in Apache you must use mod_rewrite, no other directive can do the exact thing alone. Here's an example: Code:
RewriteEngine on
RewriteCond %{Remote_Addr} ^10\.150\.0\.22$
RewriteRule ^(.*) http://my_server/users/ [R,L]
|
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > client ip based redirecting |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|