Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mod Rewrite by IP address to another directory

Status
Not open for further replies.

jamesspo

Technical User
Apr 23, 2001
4
GB
Hi, I have been unable to redirect by IP to another directory in the same webserver.

I need to redirect an IP to a specific file, regardless of what directory or page the user has entered the web application.

My attempt so far has been:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} 100.100.100.100 [OR]
RewriteCond %{REMOTE_ADDR} 200.200.200.200
RewriteRule .* /foo/bar.htm

The above example just loops for ever...

Any help available for Mr Frustrated of Wiggan ?
 
Add something like

RewriteCond %{REQUEST_URL} !/foo/bar.htm
RewriteCond %{REMOTE_ADDR} 100.100.100.100 [OR]
RewriteCond %{REMOTE_ADDR} 200.200.200.200
RewriteRule .* /foo/bar.htm

if it has been processed to /foo/bar, don't reevaluate

\0
 
Actually, I'm trying to do the same thing but also pass on the page that they were trying to reach.

How do I do that?

RewriteRule .* /foo/bar.php?c=$1

doesn't seem to work.

Thanks
 
Well, RewriteRule .* doesn't work because I need the ().

However, now it passes on the information, but its always "index.php" even if I try accessing it using another filename or directory.

Could there be a loop going on?

Thanks
 
Thanks for the tip.
Where should I add this, in httpd.conf?

Thanks
 
Yes, in httpd.conf

for readability, I'd put in near my rewrite rules and
rewrite engine on statements

Issue /usr/sbin/apachectl restart so apache re reads the conf file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top