Jump to content

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 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.