Rewrite to SE friendly URL, causing infinite loop
5 posts
• Page 1 of 1
Rewrite to SE friendly URL, causing infinite loop
I'm trying to rewrite /page.asp?page_id=123 to /new-page.asp but I'm getting an infinite loop
RewriteCond %{QUERY_STRING} ^page_id=123$
RewriteRule ^/page\.asp$ /new-page.asp? [NC,R=301,L]
RewriteRule ^/new-page\.asp$ /page.asp?page_id=123 [NC,L]
I've read that adding the following before the above can prevent internal redirects, and prevent a loop
RewriteCond %{ENV:REDIRECT_STATUS} !200
Although it doesn't fix the issue, maybe it's only for Apache?
RewriteCond %{QUERY_STRING} ^page_id=123$
RewriteRule ^/page\.asp$ /new-page.asp? [NC,R=301,L]
RewriteRule ^/new-page\.asp$ /page.asp?page_id=123 [NC,L]
I've read that adding the following before the above can prevent internal redirects, and prevent a loop
RewriteCond %{ENV:REDIRECT_STATUS} !200
Although it doesn't fix the issue, maybe it's only for Apache?
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Rewrite to SE friendly URL, causing infinite loop
Hello,
The variables supported by ISAPI_Rewrite are described here - http://www.helicontech.com/isapi_rewrite/doc/RewriteCond.htm
The rules you're using are correct and shouldn't be looping. There's supposed to be something else. Lets see rewrite.log for a testing request. Logging issues are described in FAQ - http://www.helicontech.com/forum/10648-FAQ.html
Regards
Andrew
The variables supported by ISAPI_Rewrite are described here - http://www.helicontech.com/isapi_rewrite/doc/RewriteCond.htm
The rules you're using are correct and shouldn't be looping. There's supposed to be something else. Lets see rewrite.log for a testing request. Logging issues are described in FAQ - http://www.helicontech.com/forum/10648-FAQ.html
Regards
Andrew
Re: Rewrite to SE friendly URL, causing infinite loop
Hi Andrew,
Thanks for your reply, here are the relevant entries from the rewrite.log. It seems to be doing the initial redirect correctly and then the rewrite but then is matching again to do the redirect again.
Mon, 08-Apr-2013 11:28:43 GMT (3) applying pattern '^/page\.asp$' to uri '/page.asp'
Mon, 08-Apr-2013 11:28:43 GMT (4) RewriteCond: input='page_id=123' pattern='^page_id=123$' => matched
Mon, 08-Apr-2013 11:28:43 GMT (1) escaping /new-page.asp
Mon, 08-Apr-2013 11:28:43 GMT (2) explicitly forcing redirect with http://www.example.com/new-page.asp
Mon, 08-Apr-2013 11:28:43 GMT (2) internal redirect with /page.asp?page_id=123 [INTERNAL REDIRECT]
Mon, 08-Apr-2013 11:28:43 GMT (2) init rewrite engine with requested uri /new-page.asp
Mon, 08-Apr-2013 11:28:43 GMT (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
Mon, 08-Apr-2013 11:28:43 GMT (3) applying pattern '^/new-page\.asp$' to uri '/new-page.asp'
Mon, 08-Apr-2013 11:28:43 GMT (1) Rewrite URL to >> /page.asp?page_id=123
Mon, 08-Apr-2013 11:28:43 GMT (2) rewrite '/new-page.asp' -> '/page.asp?page_id=123'
Mon, 08-Apr-2013 11:28:43 GMT (2) internal redirect with /page.asp?page_id=123 [INTERNAL REDIRECT]
Mon, 08-Apr-2013 11:28:43 GMT (2) init rewrite engine with requested uri /page.asp?page_id=123
Mon, 08-Apr-2013 11:28:43 GMT (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
Mon, 08-Apr-2013 11:28:43 GMT (3) applying pattern '^/page\.asp$' to uri '/page.asp'
Mon, 08-Apr-2013 11:28:43 GMT (4) RewriteCond: input='page_id=123' pattern='^page_id=123$' => matched
Mon, 08-Apr-2013 11:28:43 GMT (1) escaping /new-page.asp
Mon, 08-Apr-2013 11:28:43 GMT (2) explicitly forcing redirect with http://www.example.com/new-page.asp
Mon, 08-Apr-2013 11:28:43 GMT (2) internal redirect with /page.asp?page_id=123 [INTERNAL REDIRECT]
Mon, 08-Apr-2013 11:28:56 GMT (2) init rewrite engine with requested uri /new-page.asp
Mon, 08-Apr-2013 11:28:56 GMT (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
If you need anymore information let me know.
Thanks for your reply, here are the relevant entries from the rewrite.log. It seems to be doing the initial redirect correctly and then the rewrite but then is matching again to do the redirect again.
Mon, 08-Apr-2013 11:28:43 GMT (3) applying pattern '^/page\.asp$' to uri '/page.asp'
Mon, 08-Apr-2013 11:28:43 GMT (4) RewriteCond: input='page_id=123' pattern='^page_id=123$' => matched
Mon, 08-Apr-2013 11:28:43 GMT (1) escaping /new-page.asp
Mon, 08-Apr-2013 11:28:43 GMT (2) explicitly forcing redirect with http://www.example.com/new-page.asp
Mon, 08-Apr-2013 11:28:43 GMT (2) internal redirect with /page.asp?page_id=123 [INTERNAL REDIRECT]
Mon, 08-Apr-2013 11:28:43 GMT (2) init rewrite engine with requested uri /new-page.asp
Mon, 08-Apr-2013 11:28:43 GMT (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
Mon, 08-Apr-2013 11:28:43 GMT (3) applying pattern '^/new-page\.asp$' to uri '/new-page.asp'
Mon, 08-Apr-2013 11:28:43 GMT (1) Rewrite URL to >> /page.asp?page_id=123
Mon, 08-Apr-2013 11:28:43 GMT (2) rewrite '/new-page.asp' -> '/page.asp?page_id=123'
Mon, 08-Apr-2013 11:28:43 GMT (2) internal redirect with /page.asp?page_id=123 [INTERNAL REDIRECT]
Mon, 08-Apr-2013 11:28:43 GMT (2) init rewrite engine with requested uri /page.asp?page_id=123
Mon, 08-Apr-2013 11:28:43 GMT (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
Mon, 08-Apr-2013 11:28:43 GMT (3) applying pattern '^/page\.asp$' to uri '/page.asp'
Mon, 08-Apr-2013 11:28:43 GMT (4) RewriteCond: input='page_id=123' pattern='^page_id=123$' => matched
Mon, 08-Apr-2013 11:28:43 GMT (1) escaping /new-page.asp
Mon, 08-Apr-2013 11:28:43 GMT (2) explicitly forcing redirect with http://www.example.com/new-page.asp
Mon, 08-Apr-2013 11:28:43 GMT (2) internal redirect with /page.asp?page_id=123 [INTERNAL REDIRECT]
Mon, 08-Apr-2013 11:28:56 GMT (2) init rewrite engine with requested uri /new-page.asp
Mon, 08-Apr-2013 11:28:56 GMT (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
If you need anymore information let me know.
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Rewrite to SE friendly URL, causing infinite loop
That's strange. Redirect and rewrite shouldn't be looping.
One of the possibilities - double registration - http://www.helicontech.com/articles/isapi_rewrite-double-registration/
Second possibility that you need to use NS flag in both rules, however, it's unnecessary in cases like this.
Do you have any of other products installed on the server?
Regards
Andrew
One of the possibilities - double registration - http://www.helicontech.com/articles/isapi_rewrite-double-registration/
Second possibility that you need to use NS flag in both rules, however, it's unnecessary in cases like this.
Do you have any of other products installed on the server?
Regards
Andrew
Re: Rewrite to SE friendly URL, causing infinite loop
Hi Andrew
I changed the IIS ISAPI filter setup from local registration to global registration and this has solved the problem. Maybe it was due to having the full trial version first and then switching to the Lite version, that caused the config issue?
Thanks again for your help.
I changed the IIS ISAPI filter setup from local registration to global registration and this has solved the problem. Maybe it was due to having the full trial version first and then switching to the Lite version, that caused the config issue?
Thanks again for your help.
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 18 guests