XpertWorlock Posted June 29, 2010 Share Posted June 29, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/206196-redirecting-loop-get-form/ Share on other sites More sharing options...
cags Posted June 29, 2010 Share Posted June 29, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/206196-redirecting-loop-get-form/#findComment-1078901 Share on other sites More sharing options...
XpertWorlock Posted June 30, 2010 Author Share Posted June 30, 2010 Thanks, those little tricks you never seem to learn soon enough Quote Link to comment https://forums.phpfreaks.com/topic/206196-redirecting-loop-get-form/#findComment-1079001 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.