Jump to content

Redirecting loop (GET form)


XpertWorlock

Recommended Posts

Seem to have a loop occurring, can't seem to figure out how to stop it.

 

 

EXAMPLE :

 

newsArchives.php?month=5&year=2010

 

 

RewriteRule ^newsArchives/([0-9]+)/([0-9]+)/?$ /newsArchives\.php?month=$1&year=$2 [NC,L]


RewriteCond %{QUERY_STRING} ^month=([0-9]+)&year=([0-9]+)$
RewriteRule ^newsArchives.php$ /newsArchives/%1/%2/? [NC,R=301,L]

 

The top one is for a different script, but I am assuming the bottom one is changing to the top rewrite and than looping over and over.

 

Any quick ideas how to fix?

 

Link to comment
https://forums.phpfreaks.com/topic/206196-redirecting-loop-get-form/
Share on other sites

Well the simple answer is you fix your site so that it uses the 'pretty URLs' not the ones with a query_string. A 'hacky' way of preventing it is to track which you've redirected...

 

RewriteCond %{QUERY_STRING} !rewritten=true$
RewriteCond %{QUERY_STRING} ^month=([0-9]+)&year=([0-9]+)
RewriteRule ^newsArchives.php$ /newsArchives/%1/%2/? [R=302]

RewriteRule ^newsArchives/([0-9]+)/([0-9]+)/?$ /newsArchives\.php?month=$1&year=$2&rewritten=true 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.