What's wrong with this rule?

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 2
Joined: 04 Mar 2013, 19:11

What's wrong with this rule?

04 Mar 2013, 19:15

RewriteEngine On
RewriteCompatibility2 On
RepeatLimit 200
RewriteBase

RewriteRule ^/blog/?$ /blog/default.aspx [NC,L,R=301]

Undesired result:
http://example.com/blog -> http://example.com/blog/

Desired results:
http://example.com/blog -> http://example.com/blog/default.aspx
http://example.com/blog/ -> http://example.com/blog/default.aspx

What am I missing? What am I doing wrong?
ISAPI_Rewrite 3 is running on Windows Server 2012 with IIS 8. Other rules work correctly.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: What's wrong with this rule?

04 Mar 2013, 23:49

Hello,

This one is correct and, i assume, also works correctly.
My guess is that you have another rule that takes place after this redirect. For testing purposes you can try ro comment out all other rules and run this testing request.

Also, you may try to provide us with the rewrite.log for a testing request.
Logging issues are described in FAQ - http://www.helicontech.com/forum/forum_posts-TID-10648.htm

Regards
Andrew

User avatar
Posts: 2
Joined: 04 Mar 2013, 19:11

Re: What's wrong with this rule?

05 Mar 2013, 13:36

Thanks for the response Andrew.

I was under the impression that the L flag caused the rule to be the last one that is processed if it matches. Is that not the case?

I'm generating some log files now.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: What's wrong with this rule?

05 Mar 2013, 19:05

Well, let me show you how L works:

Code: Select all
RewriteRule /a /b [NC,L]
RewriteRule /b /c [NC]
RewriteRule /c /d [NC]

Scenario 1: You request /a and get content from /b. Second rule will not be executed.
Scenario 2: You request /b directly and get content from /d, because after the second rule you instantly matched the third rule.

Code: Select all
RewriteRule /a /b [NC,R=301,L]
RewriteRule /b /c [NC,R=301,L]
RewriteRule /c /d [NC,R=301,L]

Scenario: you request /a and get redirected to /d. Why? Each of the rules creates a redirect(a new incoming request). So you'll get 3 simultaneous redirects and will end up at /d.

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 6 guests