IIRF rules changes the URL coming in request

Topics: Developer Forum
May 18, 2010 at 1:48 PM

I have implemented IIRF rules on IIS in my VB application.

a sample rule-

RewriteRule ^/india-([^/]+)-Admission/(\d+)(.*)$  /schooldetail.aspx?schoolid=$2 [I,L]

RewriteRule urlA  urlB [I,L]

now browser shows the URLA in address bar. but when I try to access the Request.URL or Request.RawUrl property in VB code then I get URLB(the rewritten rule- I want the url which is shown in address bar-the URLA).

I want this to redirect the user to earlier URL .

May 18, 2010 at 10:15 PM

You can get the original un-rewritten URL in downstream apps, via the HTTP_X_REWRITE_URL server variable.
You need to use the [U] modifier.  See the documentation for more information.

May 19, 2010 at 4:35 AM

2 questions-

1) how I can access server variable HTTP_X_REWRITE_URL. can I access this like Request("X-Rewrite-Url")

2) I have around 50 rules. will it be a problem if I specify a U flag in all the rules. basically I want to maintain the return URL (the url of the last page he visited) at every point of time, so  have to insert this U flag in all urls.

May 19, 2010 at 2:37 PM

#1 - About server variables, If you are using ASPNET then the syntax is ServerVariables("HTTP_X_REWRITE_URL") .

#2 - yes.  There's an open request to make the "U" think a universal option.  But for now you have to put it in your rule.s