Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 27th, 2002, 04:42 PM
tank80's Avatar
tank80 tank80 is offline
php-oriented object
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: 0x9832053
Posts: 173 tank80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 49 sec
Reputation Power: 8
Send a message via ICQ to tank80
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!

Reply With Quote
  #2  
Old March 27th, 2002, 06:53 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #3  
Old March 28th, 2002, 03:00 AM
tank80's Avatar
tank80 tank80 is offline
php-oriented object
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: 0x9832053
Posts: 173 tank80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 49 sec
Reputation Power: 8
Send a message via ICQ to tank80
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

Reply With Quote
  #4  
Old March 28th, 2002, 07:55 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> 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]

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > client ip based redirecting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway