问题
I am using Iconic's IIRF URL Rewriting Engine on IIS and the "fancy" URLs are something like this:
http://some-website.com/some-function/418/some-keyword-rich-filename.html
This example URL corresponds to:
http://some-website.com/some-function.asp?SOME-ID=418
Now inside the some-function.asp file I need to know the page that was requested by the browser. I went through all IIS variables but wasn't able to find the value /some-function/418/some-keyword-rich-filename.html
inside any of them.
As a side note, I need this information to send 301 redirect to browsers. E.g. if the browser requests:
http://some-website.com/some-function/418/index.html
I first need to send the browser to:
http://some-website.com/some-function/418/some-keyword-rich-filename.html
And this is why I need the original url for comparison.
回答1:
For IIRF, this is called unmangling and can be achieved by using the modifier U
.
From the IIRF manual:
U = Store original url in server variable HTTP_X_REWRITE_URL
Simply add the modifier U
to the RewriteRule
for which you would like to retain the original url. For example:
RewriteRule ^/some-function/(\d+)/(.*)$ /some-function.asp?SOME-ID=$1 [I,U,L]
Then, in the code of your page some-function.asp
, you may access the original url like this (classic ASP):
Request.ServerVariables("HTTP_X_REWRITE_URL")
来源:https://stackoverflow.com/questions/3895956/how-to-get-the-originally-requested-url-when-using-iirf-url-rewriting-engine