Forum Moderators: phranque
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?
# 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