Rewrite based on REMOTE_ADDR

 
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting
View previous topic :: View next topic  
Author Message
koffie
-


Joined: 26 Mar 2009
Posts: 1

PostPosted: Thu Mar 26, 2009 9:39 am    Post subject: Rewrite based on REMOTE_ADDR Reply with quote

I'm stuck with a rewrite rule, probably because of the fact I don't understand regular expressions :(

What I want is the following:
If some asks for the URL http://127.0.0.1/cgi-bin/cgifile?var1=1234$var2=somethingelse

It should rewrite it to:
http://%{REMOTE_ADDR}/cgi-bin/cgifile?var1=%{REMOTE_ADDR}:1234$var2=somethingelse

I have set it to do this when the Virtual Path Regular Expression is /cgi-bin/cgifile
Problem is, the rewritten URL is on the same server. So if I would launch this rewrite it would come in a loop becuase of the same Virtual Path.

I think it should be triggered by the condition if the first part of the URL is http://127.0.0.1
Another condition could be to look if in the requested URL would be a match for the string "var1=1234" (because that part of the string is going to be rewritten it would be a safe condition).

can anyone help me with this problem?


=[EDIT]=
As allways, you find the solution right after posting your problem ;)
I was focussing on REQUEST_URL, bu I should use REQUEST_UR.
When I add the follwoing condition:

Variable: REQUEST_URI
Operator: matches with
Regular Expression: ^/cgi-bin/cgifile\?var1=1234(.*)

It works :)
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 900
Location: Michigan, USA

PostPosted: Thu Mar 26, 2009 1:45 pm    Post subject: Reply with quote

Glad you found your solution. And welcome to the message board!

As for your regular expression, you might be getting stuck in an infinite loop.
The only time the the URL would be called with 127.0.0.1 would be when the server computer is asking for a server resource. Thus the REMOTE_ADDR would be 127.0.0.1 as well.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group