What's wrong with this rule?
4 posts
• Page 1 of 1
What's wrong with this rule?
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.
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.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: What's wrong with this rule?
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
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
Re: What's wrong with this rule?
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.
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.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: What's wrong with this rule?
Well, let me show you how L works:
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.
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
- 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
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests