View previous topic :: View next topic |
Author |
Message |
koffie -
Joined: 26 Mar 2009 Posts: 1
|
Posted: Thu Mar 26, 2009 9:39 am Post subject: Rewrite based on REMOTE_ADDR |
|
|
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 |
|
|
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Thu Mar 26, 2009 1:45 pm Post subject: |
|
|
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 |
|
|
|