How to avoid a redirect-rewrite loop

Topics: Developer Forum, User Forum
Dec 15, 2007 at 1:29 PM
I use ISAPI Rewrite to rewrite our URLs to make them more intuitive. The site is for a school and the administration needs to communicate many of its URLs via telephone. So I have changed the links from ".org/academics.asp?c=history&t=mrsmith&s=studentnumber" - to - ".org/academics/history/mrsmith/studentnumber/" using the following rule.

RewriteRule ^/academics/([^/]+)/([^/]+)/(\d+)/$ /academics.asp?c=$1&t=$2&s=$3
This has been a huge success and the administration and parents are thrilled - thanks cheeso for making me a hero!

The problem is that I now need to update the site map to add a few new pages. I now realize our sitemap is completely different (as it should be) in that all of the URLs list are now much more intuitive. However, we have many pages listed in the search engines that we do not want to abandon. In fact, these links still work because the structure of the site hasn't changed. However we would like the search engines to display the new URL - thus the new sitemap.

So I tried to use the following rule to rewrite the URLs already present in the search engine results to redirect to the new URLs. (I'm sure you can already see the problem coming.)
RewriteRule ^academics.asp?c=([^/]+)&t=([^/]+)&s=(\d+)/$ /academics/([^/]+)/([^/]+)/(\d+)/ [R=301]
This results in the following error message:

"Firefox has detected that the server is redirecting the request for this address in a way that will never complete."

In other words, a loop. Is there a way to redirect the old nasty querystrings to the new intuitive links without jumping into a loop. I fear that if I simply abandon those old nasty querystring links without appropriately redirecting them, I will push the school's website back into another six month google sandbox.

Thanks.
Coordinator
Jan 8, 2008 at 12:40 PM
Good question, but unfortunately I'm probably not the best person to answer it.

Your question is something along the lines of, "How can I employ IIRF in such a way that the search engines won't lose context?"

Maybe a better way to explore this issue is to ask - "how can I change URLs and not confuse search engines?" That's a question that is independent of IIRF, and maybe there is a more general approach. Maybe try http://search.msn.com/results.aspx?q=change+URL"Search+engine"+redirect&FORM=QBHP as a start.
Jan 15, 2008 at 4:33 PM
I implemented a relatively simple solution. In short, I very careful place a last rule L parameter in select urls listed in the SERP. When the URL in the SERP is recieved it is rewritten to the new URL format. When that new rewritten URL is then received it is rewritten again to the appropriate location but now it is processed with a last rule evaluated parameter - which cuts of the loop.

This works - but it still managed to screw up the search engine and out pages dropped from a pagerank of 4 down to 1. A serious drag. I wouldn't recommend this to sites that thrive on pagerank. Its probably not worth it.



Cheeso wrote:
Good question, but unfortunately I'm probably not the best person to answer it.

Your question is something along the lines of, "How can I employ IIRF in such a way that the search engines won't lose context?"

Maybe a better way to explore this issue is to ask - "how can I change URLs and not confuse search engines?" That's a question that is independent of IIRF, and maybe there is a more general approach. Maybe try http://search.msn.com/results.aspx?q=change+URL"Search+engine"+redirect&FORM=QBHP as a start.