problem with infinite loop

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 32
Joined: 14 Apr 2012, 07:28

problem with infinite loop

12 May 2013, 16:32

Hi,

I use the pro version and have a problem with redirect resulting in an infinite loop.


the problem happens with user friendly url.

given this:

RewriteCond %{HTTP:Host} ^www\.pet-needs\.de$ [NC]
RewriteRule ^(admin/.+) $1 [NC,L]
RewriteRule ^([^&]*)/([^&]*)/(.*)$ index.asp?m__id=${mapmid2:$1}&ani=${mapani2:$2}&pag=$3 [L]
RewriteRule ^home$ index.asp [L]

if you enter url.com/home it redirects to url.com/index.asp which is ok but if I now add

RewriteRule ^([^&]*)$ index.asp?m__id=${mapmid2:$1} [L]

(the mapping file works for the other rule before) the page cannot be shown and results in an infinite redirect loop error. Why as it should have matched the home rule before and stop the script?

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: problem with infinite loop

13 May 2013, 07:35

Hello,

Please try to change the rule you add like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^&.]+)$ index.asp?m__id=${mapmid2:$1} [L]

User avatar
Posts: 32
Joined: 14 Apr 2012, 07:28

Re: problem with infinite loop

13 May 2013, 14:46

Hi Anton,

Yes, that works. it also appends variables to match url type m__id=64&ani=2&pag=1

with rewrite condition RewriteCond %{QUERY_STRING} ^m__id=([^&]*)&ani=([^&]*)&pag=1 [NC] which is fine but now it does not make the redirect to the user friendly url with

RewriteRule ^index\.asp$ /${mapmid:%1}/${mapani:%2}/1? [NC,R=301,L]

which is situated a few row above. :(

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: problem with infinite loop

16 May 2013, 04:39

Hello,

Can you show me the entire config, because there is definitely a cond before this rule:

RewriteRule ^index\.asp$ /${mapmid:%1}/${mapani:%2}/1? [NC,R=301,L]

It would be easier to fix it seeing the whole picture.

User avatar
Posts: 32
Joined: 14 Apr 2012, 07:28

Re: problem with infinite loop

16 May 2013, 17:32

Hi Anton,

here we go

Code: Select all
RewriteEngine on
RewriteBase /

RewriteMap mapmid txt:C:/Program Files/Helicon/ISAPI_Rewrite3/mapfilemid.txt
RewriteMap mapmid2 txt:C:/Program Files/Helicon/ISAPI_Rewrite3/mapfilemidre.txt
RewriteMap mapani txt:C:/Program Files/Helicon/ISAPI_Rewrite3/mapfileanide.txt
RewriteMap mapani2 txt:C:/Program Files/Helicon/ISAPI_Rewrite3/mapfileanidere.txt
RewriteMap mapgid txt:D:/var/www/root_zotto/pet-needs.de/wwwroot/Admin/mapfilegidde.txt
RewriteMap mapgid2 txt:D:/var/www/root_zotto/pet-needs.de/wwwroot/Admin/mapfilegiddere.txt


RewriteCond %{HTTP:Host} ^www\.pet-needs\.de$ [NC]
RewriteCond %{REQUEST_URI} ^/index\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^m__id=([^&]*)&ani=([^&]*)&pag=1 [NC]

RewriteCond ${mapmid:${lower:%1}|NOT_FOUND} !NOT_FOUND
RewriteCond ${mapani:${lower:%2}|NOT_FOUND} !NOT_FOUND

RewriteRule ^index\.asp$ /${mapmid:%1}/${mapani:%2}/1? [NC,R=301,L]

#RewriteCond %{QUERY_STRING} ^gid=([^&]*) [NC]

#RewriteCond ${mapmid:${lower:%1}|NOT_FOUND} !NOT_FOUND
#RewriteCond ${mapani:${lower:%2}|NOT_FOUND} !NOT_FOUND

#RewriteRule ^index\.asp$ /${mapgid:%1}? [NC,R=301,L]

#RewriteCond %{QUERY_STRING} ^m__id=([^&]*) [NC]
#RewriteRule ^index\.asp$ /${mapmid:%1}? [NC,R=301,L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


RewriteCond %{HTTP:Host} ^www\.pet-needs\.de$ [NC]
RewriteRule ^(admin/.+) $1 [NC,L]
RewriteRule ^([^&]*)/([^&]*)/(.*)$ index.asp?m__id=${mapmid2:$1}&ani=${mapani2:$2}&pag=$3 [L]
RewriteRule ^home$ index.asp [L]
#RewriteRule ^([^&]*)$ index.asp?gid=${mapgid2:$1} [L]
RewriteRule ^([^&.]+)$ index.asp?m__id=${mapmid2:$1}&ani=1&pag=1 [L]

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: problem with infinite loop

20 May 2013, 08:28

Hello,

Please try to fix your config like this:


RewriteEngine on
RewriteBase /

RewriteMap mapmid txt:C:/Program Files/Helicon/ISAPI_Rewrite3/mapfilemid.txt
RewriteMap mapmid2 txt:C:/Program Files/Helicon/ISAPI_Rewrite3/mapfilemidre.txt
RewriteMap mapani txt:C:/Program Files/Helicon/ISAPI_Rewrite3/mapfileanide.txt
RewriteMap mapani2 txt:C:/Program Files/Helicon/ISAPI_Rewrite3/mapfileanidere.txt
RewriteMap mapgid txt:D:/var/www/root_zotto/pet-needs.de/wwwroot/Admin/mapfilegidde.txt
RewriteMap mapgid2 txt:D:/var/www/root_zotto/pet-needs.de/wwwroot/Admin/mapfilegiddere.txt


RewriteCond %{HTTP:Host} ^www\.pet-needs\.de$ [NC]
RewriteCond %{REQUEST_URI} ^/index\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^m__id=([^&]*)&ani=([^&]*)&pag=1 [NC]

RewriteCond ${mapmid:${lower:%1}|NOT_FOUND} !NOT_FOUND
RewriteCond ${mapani:${lower:%2}|NOT_FOUND} !NOT_FOUND

RewriteRule ^index\.asp$ /${mapmid:%1}/${mapani:%2}/1? [NC,R=301,L]

#RewriteCond %{QUERY_STRING} ^gid=([^&]*) [NC]

#RewriteCond ${mapmid:${lower:%1}|NOT_FOUND} !NOT_FOUND
#RewriteCond ${mapani:${lower:%2}|NOT_FOUND} !NOT_FOUND

#RewriteRule ^index\.asp$ /${mapgid:%1}? [NC,R=301,L]

#RewriteCond %{QUERY_STRING} ^m__id=([^&]*) [NC]
#RewriteRule ^index\.asp$ /${mapmid:%1}? [NC,R=301,L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP:Host} ^www\.pet-needs\.de$ [NC]
RewriteRule ^(admin/.+) $1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^&./]+)/([^&/.]+)/(.*)$ index.asp?m__id=${mapmid2:$1}&ani=${mapani2:$2}&pag=$3 [L]

RewriteRule ^home$ index.asp [L]
#RewriteRule ^([^&./]+)$ index.asp?gid=${mapgid2:$1} [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/&.]+)$ index.asp?m__id=${mapmid2:$1}&ani=1&pag=1 [L]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 18 guests