Forum Moderators: phranque

Message Too Old, No Replies

htaccess modrewrite -> redirect-limit is exceeded

some rules get errors, need modrewrite expert?

         

Luky

7:48 am on Aug 9, 2005 (gmt 0)

10+ Year Member



Hi,

i have a litte problem, i have some forum which should work with modrewrite.
nearly everything works expect:

if somebody request this urls it is correctly rewritten to:
www.domain.de/showtopic.php?thread=389343 -> www.domain.de/t389343.htm

if somebody requests the url with some more pages (pagenum!)
www.domain.de/showtopic.php?thread=389343&pagenum=2
it doesn't work and after some time you get the error message redirect-limit is exceeded (i hope this is the right translation)

this is my htaccess code:

RewriteEngine On

# Catch New + Rewrite
RewriteRule ^t([0-9]+)-?([0-9]+)?\.htm$ showtopic.php?thread=$1&pagenum=$2 [QSA,L]

# Catch old Urls
RewriteCond %{QUERY_STRING} ^thread=([0-9]+)&pagenum=([0-9]+)$
RewriteRule ^showtopic\.php$ /t%1-%2.htm? [R=301,L]
RewriteCond %{QUERY_STRING} ^thread=([0-9]+)$
RewriteRule ^showtopic\.php$ /t%1.htm? [R=301,L]

does anyone get an idea what works wrong?

jd01

8:40 am on Aug 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



# Catch New + Rewrite
RewriteRule ^t([0-9]+)-?([0-9]+)?\.htm$ showtopic.php?thread=$1&pagenum=$2 [QSA,L]

# Catch old Urls
RewriteCond %{QUERY_STRING} ^thread=([0-9]+)&pagenum=([0-9]+)$
RewriteRule ^showtopic\.php$ /t%1-%2.htm? [R=301,L]

This is an infinite loop... the first rule rewrites the static URL to the dynamic page silently (internally), the second rule rewrites the the dynamic request to the static page in the browser (externally) then the first rule rewrites the static page to the dynamic URL silently, and on, and on, and on...

You can avoid this by rewriting only external (original) requests for the 'old' URL using THE_REQUEST:

RewriteCond %{THE_REQUEST} \?thread=([0-9]+)&pagenum=([0-9]+) [NC]
RewriteRule ^showtopic\.php$ /t%1-%2.htm? [R=301,L]

Hope this helps.

Justin

Luky

8:49 am on Aug 9, 2005 (gmt 0)

10+ Year Member



Hi jd01,

thank you so very much!
it works!

you rescued my day ;)
thanks thanks thanks!