3

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.

Kev
  • 118,037
  • 53
  • 300
  • 385
Salman A
  • 262,204
  • 82
  • 430
  • 521

1 Answers1

6

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")
marapet
  • 54,856
  • 12
  • 170
  • 184