rewriterule redirects the first time and rewrites the other requests

Topics: Developer Forum, Project Management Forum, User Forum
Apr 7, 2011 at 10:36 PM

Hi,

I have installed IIRF 2.1 on a win 2003 box with IIS 6.0.

The global ini is the default one.

The web site has 2 virtual dirs which need to be rewritten to a page.asp?somethingsomething in their parent site.

I placed 2 iirf.ini in the phisical directory of the virtual dirs.

When I call the www.site.com/vdir the first time  the browser shows the rewritten url like www.site.com/,page.asp?somethingsomething if I open a second browser tab or type again the www.site.com/vdir the rewrite works as expected.

Why is this happening?

Thanks.

Coordinator
Apr 8, 2011 at 3:18 PM

I don't know why it is happening.  Sometimes, when you see something you don't expect, the issue is a stale browser cache. The browser is just redisplaying cached content, rather than requesting new content.  Likely this is not what you are seeing, since you said that you see the rewritten URL in the browser. I take it by that, you mean to say that the URL www.site.com/,page.asp?somethingsomething appears in the browser address bar.  Is that right?  If that's the case, then the server (whether IIS or IIRF or ?) has not rewritten the URL.  It has redirected. But based on what you said, I am not sure if you are actually seeing an updated URL in the browser address bar.  

Maybe you could clarify just what you are seeing.  Also, show your IIRF.ini files.

 

Apr 8, 2011 at 8:57 PM

Hi,

Thank you very much for your post.

The browser is showing the correct rewritten URL page but is showing it in the browser address bar the first time. I have tried from different browsers and different computers and the behaviour is the same. I will post the iirf.ini files as soon as I can connect with the server after the week end.

Again thanks.

 

Coordinator
Apr 9, 2011 at 9:51 AM

Also please read about "courtesy redirects" in IIS:  http://support.microsoft.com/kb/298408 .

This can appear to be from IIRF, when it is not.  It applies when making a request for a folder URL, with no trailing slash.

 

Apr 11, 2011 at 10:14 PM

Hi,

first of all thank you very much for your help.

Nothing changes if I add or not a / at the end of my rewritten URL (www.site.com/vdir or www.site.com/vdir/)

The IIRF.INI which I am using is the following:

# IIRF ini file

# version 2.1

# Thu, 7 Apr 2011 

#

# ============================================

RewriteEngine ON

RewriteRule  ^/vdir   /filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85

 

Coordinator
Apr 13, 2011 at 1:09 PM

Check my prior reply - please respond directly to ALL the questions I posted there.

I don't understand what you mean by this:

> The browser is showing the correct rewritten URL page but is showing it in the browser address bar the first time.

???

Apr 13, 2011 at 5:56 PM

Hi,

thank you again for your patience and your time.

What I mean is:

the first time that I input in the browser address bar the url http://www.mysite.com/vdir I will get the page correct

page www.mysite.com/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85 which is the page I need to display but the full url will now appear in the browser address bar. If I open a new browser tab and type again the http://www.mysite.com/vdir url I will see the correct page but not the long address in the browser address bar which will show http://www.mysite.com/vdir as expected.

If can be of any help, the http://localhost/iirfstatus page says

Ini file timestamp (file not found)

Thanks again.

Coordinator
Apr 13, 2011 at 8:37 PM

ok, thanks for the full explanation.

my first reaction:

the iirfstatus page looks wrong.  Make sure you are on the latest IIRF.  I don't know why it would look like you have there, unless your cut-and-paste is truncated.

Regarding the odd behavior - I'd like to see the IIRF log file for those 2 requests.  The first one that puts a large URL in the browser address bar, and the second one that does not.

Can you post the IIRF log file?

Apr 13, 2011 at 11:40 PM

Hi,

iirfstatus was a truncated cut-and-paste and also the wrong one! Sorry. iirfstatus is OK now.

Please find below the log for the 2 transactions generated as follows:

1) enabled the RewriteLogLevel 5 in the iirf.ini of the vir dir called funds

2) open a new instance of IE 8.0 and typed the http://www.mysite.com/vdir URL resulting in seeing the long one www.mysite.com/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85

3) open a new tab in the browser and typed http://www.mysite.com/vdir URL resulting in seeing http://www.mysite.com/vdir

N.B.: mysite is not the real name of the site, the vir dir is called funds and filename is not the real name of the .aspx page

Thank you very much for your help.

Wed Apr 13 23:19:55 -  8624 - -------------------------------------------------------
Wed Apr 13 23:19:55 -  8624 - Ionic ISAPI Rewriting Filter (IIRF) 2.1.1.23 x86 RELEASE
Wed Apr 13 23:19:55 -  8624 - IIRF was built on: May 30 2010 13:26:57
Wed Apr 13 23:19:55 -  8624 - Cached: DLL_PROCESS_ATTACH
Wed Apr 13 23:19:55 -  8624 - Cached: Process ID: 9572
Wed Apr 13 23:19:55 -  8624 - Cached: ReadServerConfig: C:\Program Files\Ionic Shade\IIRF 2.1\IirfGlobal.ini(23): Filter Priority is now: HIGH (0x80000)
Wed Apr 13 23:19:55 -  8624 - Cached: ReadServerConfig: C:\Program Files\Ionic Shade\IIRF 2.1\IirfGlobal.ini(46): NotifyLog setting is now: OFF
Wed Apr 13 23:19:55 -  8624 - Cached: ReadServerConfig: C:\Program Files\Ionic Shade\IIRF 2.1\IirfGlobal.ini(63): RewriteEngine setting is now: ON
Wed Apr 13 23:19:55 -  8624 - Cached: DLL_PROCESS_ATTACH - complete
Wed Apr 13 23:19:55 -  8624 - Cached: GetFilterVersion
Wed Apr 13 23:19:55 -  8624 - GetLogFile: app:'/LM/W3SVC/854224/Root/funds'  new log:'F:\websites\sjb\funds\.9572.log'
Wed Apr 13 23:19:55 -  8624 - ReadVdirConfig: actual log file 'F:\websites\sjb\funds\.9572.log'
Wed Apr 13 23:19:55 -  8624 - ReadVdirConfig: ini file: 'F:\websites\mysite\funds\Iirf.ini'
Wed Apr 13 23:19:55 -  8624 - ReadVdirConfig: ini file timestamp: 2011/04/13 23:19:33 GMT Daylight Time
Wed Apr 13 23:19:55 -  8624 - ReadVdirConfig: cfg(0x01FC5268)
Wed Apr 13 23:19:55 -  8624 - ReadVdirConfig: LogLevel = 5
Wed Apr 13 23:19:55 -  8624 - ReadVdirConfig: pass 2
Wed Apr 13 23:19:55 -  8624 - ReadVdirConfig: F:\websites\mysite\funds\Iirf.ini(10): RewriteEngine will be enabled.
Wed Apr 13 23:19:55 -  8624 - ReadVdirConfig: F:\websites\mysite\funds\Iirf.ini(13): RewriteRule (rule 1)  '^/funds'  '/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85'   (null)
Wed Apr 13 23:19:55 -  8624 - ReadVdirConfig: Done reading INI for vdir(/funds), found 1 rules (0 errors, 0 warnings) on 14 lines
Wed Apr 13 23:19:55 -  8624 - GetVdirConfig: Obtain  vdir '/LM/W3SVC/854224/Root/funds' (era=0) (rc=1) (Expired=0) (ptr=0x01FC5268)...
Wed Apr 13 23:19:55 -  8624 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Apr 13 23:19:55 -  8624 - HttpFilterProc: cfg= 0x01FC5268
Wed Apr 13 23:19:55 -  8624 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Wed Apr 13 23:19:55 -  8624 - DoRewrites
Wed Apr 13 23:19:55 -  8624 - GetHeader_AutoFree: getting 'url'
Wed Apr 13 23:19:55 -  8624 - GetHeader_AutoFree: 7 bytes   ptr:0x036A9F40
Wed Apr 13 23:19:55 -  8624 - GetHeader_AutoFree: 'url' = '/funds'
Wed Apr 13 23:19:55 -  8624 - GetServerVariable_AutoFree: getting 'QUERY_STRING'
Wed Apr 13 23:19:55 -  8624 - GetServerVariable_AutoFree: 1 bytes
Wed Apr 13 23:19:55 -  8624 - GetServerVariable_AutoFree: result ''
Wed Apr 13 23:19:55 -  8624 - GetHeader_AutoFree: getting 'method'
Wed Apr 13 23:19:55 -  8624 - GetHeader_AutoFree: 4 bytes   ptr:0x036AA050
Wed Apr 13 23:19:55 -  8624 - GetHeader_AutoFree: 'method' = 'GET'
Wed Apr 13 23:19:55 -  8624 - DoRewrites: New Url, before decoding: '/funds' 
Wed Apr 13 23:19:55 -  8624 - DoRewrites: Url (no decoding): '/funds'
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: depth=0
Wed Apr 13 23:19:55 -  8624 - GetServerVariable: getting 'SCRIPT_NAME'
Wed Apr 13 23:19:55 -  8624 - GetServerVariable: 7 bytes
Wed Apr 13 23:19:55 -  8624 - GetServerVariable: result '/funds'
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: no RewriteBase
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: Rule 1: pattern: ^/funds  subject: /funds
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: Rule 1: 1 match
Wed Apr 13 23:19:55 -  8624 - ReplaceServerVariables: alloc 65 bytes
Wed Apr 13 23:19:55 -  8624 - ReplaceServerVariables: in='/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85' out='/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85'
Wed Apr 13 23:19:55 -  8624 - GenerateReplacementString: alloc 72 bytes
Wed Apr 13 23:19:55 -  8624 - GenerateReplacementString: result '/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85'
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: Result (length 64): /filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: depth=1
Wed Apr 13 23:19:55 -  8624 - GetServerVariable: getting 'SCRIPT_NAME'
Wed Apr 13 23:19:55 -  8624 - GetServerVariable: 7 bytes
Wed Apr 13 23:19:55 -  8624 - GetServerVariable: result '/funds'
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: no RewriteBase
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: Rule 1: pattern: ^/funds  subject: /filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: Rule 1: -1 (No match)
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: returning 0
Wed Apr 13 23:19:55 -  8624 - EvaluateRules: returning 1
Wed Apr 13 23:19:55 -  8624 - DoRewrites: Rewrite Url to: '/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85'
Wed Apr 13 23:19:55 -  8624 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Apr 13 23:19:55 -  8624 - HttpFilterProc: cfg= 0x01FC5268
Wed Apr 13 23:19:55 -  8624 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Apr 13 23:19:55 -  8624 - HttpFilterProc: cfg= 0x01FC5268
Wed Apr 13 23:19:55 -  8640 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Apr 13 23:19:55 -  8640 - HttpFilterProc: cfg= 0x01FC5268
Wed Apr 13 23:19:59 -  8624 - ReleaseOrExpireVdirConfig: vdir '/LM/W3SVC/854224/Root/funds' (era=0) (rc=0) (Expired=0) (ptr=0x01FC5268)...
Wed Apr 13 23:20:04 - 10140 - IsIniFileUpdated: F:\websites\mysite\funds\Iirf.ini NO
Wed Apr 13 23:20:04 - 10140 - GetVdirConfig: Obtain  vdir '/LM/W3SVC/854224/Root/funds' (era=0) (rc=1) (Expired=0) (ptr=0x01FC5268)...
Wed Apr 13 23:20:04 - 10140 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Apr 13 23:20:04 - 10140 - HttpFilterProc: cfg= 0x01FC5268
Wed Apr 13 23:20:04 - 10140 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Wed Apr 13 23:20:04 - 10140 - DoRewrites
Wed Apr 13 23:20:04 - 10140 - GetHeader_AutoFree: getting 'url'
Wed Apr 13 23:20:04 - 10140 - GetHeader_AutoFree: 7 bytes   ptr:0x000CE2B8
Wed Apr 13 23:20:04 - 10140 - GetHeader_AutoFree: 'url' = '/funds'
Wed Apr 13 23:20:04 - 10140 - GetServerVariable_AutoFree: getting 'QUERY_STRING'
Wed Apr 13 23:20:04 - 10140 - GetServerVariable_AutoFree: 1 bytes
Wed Apr 13 23:20:04 - 10140 - GetServerVariable_AutoFree: result ''
Wed Apr 13 23:20:04 - 10140 - GetHeader_AutoFree: getting 'method'
Wed Apr 13 23:20:04 - 10140 - GetHeader_AutoFree: 4 bytes   ptr:0x058F6C90
Wed Apr 13 23:20:04 - 10140 - GetHeader_AutoFree: 'method' = 'GET'
Wed Apr 13 23:20:04 - 10140 - DoRewrites: New Url, before decoding: '/funds' 
Wed Apr 13 23:20:04 - 10140 - DoRewrites: Url (no decoding): '/funds'
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: depth=0
Wed Apr 13 23:20:04 - 10140 - GetServerVariable: getting 'SCRIPT_NAME'
Wed Apr 13 23:20:04 - 10140 - GetServerVariable: 7 bytes
Wed Apr 13 23:20:04 - 10140 - GetServerVariable: result '/funds'
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: no RewriteBase
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: Rule 1: pattern: ^/funds  subject: /funds
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: Rule 1: 1 match
Wed Apr 13 23:20:04 - 10140 - ReplaceServerVariables: alloc 65 bytes
Wed Apr 13 23:20:04 - 10140 - ReplaceServerVariables: in='/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85' out='/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85'
Wed Apr 13 23:20:04 - 10140 - GenerateReplacementString: alloc 72 bytes
Wed Apr 13 23:20:04 - 10140 - GenerateReplacementString: result '/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85'
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: Result (length 64): /filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: depth=1
Wed Apr 13 23:20:04 - 10140 - GetServerVariable: getting 'SCRIPT_NAME'
Wed Apr 13 23:20:04 - 10140 - GetServerVariable: 7 bytes
Wed Apr 13 23:20:04 - 10140 - GetServerVariable: result '/funds'
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: no RewriteBase
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: Rule 1: pattern: ^/funds  subject: /filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: Rule 1: -1 (No match)
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: returning 0
Wed Apr 13 23:20:04 - 10140 - EvaluateRules: returning 1
Wed Apr 13 23:20:04 - 10140 - DoRewrites: Rewrite Url to: '/filename.aspx?mid=1&rid=1&lid=3&ctid=6&cid=4818&t1id=85'
Wed Apr 13 23:20:04 - 10140 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Apr 13 23:20:04 - 10140 - HttpFilterProc: cfg= 0x01FC5268
Wed Apr 13 23:20:04 - 10140 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Apr 13 23:20:04 - 10140 - HttpFilterProc: cfg= 0x01FC5268
Wed Apr 13 23:20:04 -  2200 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Apr 13 23:20:04 -  2200 - HttpFilterProc: cfg= 0x01FC5268
Wed Apr 13 23:20:04 -  9284 - ReleaseOrExpireVdirConfig: vdir '/LM/W3SVC/854224/Root/funds' (era=0) (rc=0) (Expired=0) (ptr=0x01FC5268)...

 

Coordinator
Apr 14, 2011 at 2:42 PM

right - ok, I understand.

I've looked at the log, here's what I see. There are two requests documented in the IIRF log file, for "/funds" . Both are handled similarly, both requests are rewritten to the parameterized filename.aspx URL. 

As you know, a REWRITE causes no update in the browser URL address bar.  A Rewrite is a server-only action.  The browser is not notified of a server-side rewrite. 

How then, is the browser address bar being updated? I don't know.

What is even more strange is that there is no evidence of a request for the URL that you see in the browser address bar - /filename.aspx?etc&etc .  IIRF doesn't see that request.

What could explain this?  A stale browser cache might do so.  Suppose that in a previous iteration, you had used a REDIRECT for the /funds URL.  If the IE browser cache has stored this response, it may be applying this cache in response to the first request.  When you make the same request again, it may then send an actual request. Maybe. This doesn't explain why there are two requests for /funds in the IIRF log, however.

Another possibility is that the default document configured for that vdir in IIS, is set as /filename.aspx?etc&etc . That doesn't quite make sense to me either.

This will remain a puzzle until you collect additional diagnostic data, of a different type.  One additional source is a debugging HTTP Proxy, like Fiddler.  This gets installed on the browser side, and records the content of HTTP requests and responses. If you are getting a browser cache hit, it will be very evident in the HTTP traffic. 

Correlating the Fiddler data with the data in the IIRF log will provide some additional clarity.

Another suggestion - change the rule that rewrites requests to /filename.aspx?etc&etc - to invoke a different page, an .aspx file that is installed strictly for diagnostic purposes. This may give you more insight into how the rewrite is working.

Let me know what you find.