Forum Moderators: phranque

Message Too Old, No Replies

Mod_ReWrite Loop. Help!

My rwrite rules are causing an infinite loop due to a maformed URL.

         

islandlizard

5:03 am on Feb 5, 2006 (gmt 0)

10+ Year Member



Hi all,

Thanks to lots of help form here in the past, I have a bunch of wonderful rewrite rules in place. eg:

Rewrite ^/fakedir/var1/var2/ realpage.php?var=$1&var2=$2

These work fine when a URL is apssed to them correctly, however, while wandering through my Google SiteMaps errors I noticed a bit of an issue.

Somehow, Google is picking up:

[mysite.com...]

*without* any other variables.

This then gets re-written by mod-rewrite in an infiniste loop to:

musite.com/fakedir/fakedir/
mysite.com/fakedir/fakedir//fakedir//
mysite.com/fakedir/fakedir//fakedir///fakedir//

appending '/fakedir/' each time in a horrible loop.

How do I stop mod_rewrite re-processing these rewritten URLS over and over?

I've tried adding:

ReWriteOptions MaxRedirects=3

but this doesn't appear to do anything in my set up.

Can anyone help?

TIA

koen

12:44 pm on Feb 5, 2006 (gmt 0)

10+ Year Member



If I'm right, you can just append [L] as a flag to stop the rewriting.

islandlizard

3:40 pm on Feb 5, 2006 (gmt 0)

10+ Year Member



Koen,

Thanks, but that just stops other rules in the set being run.

This problem is caused by mod_rewrite then reprocessing the rewritten rule, which [L] has no effect on.

jdMorgan

3:42 pm on Feb 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This code is not at all valid:

Rewrite ^/fakedir/var1/var2/ realpage.php?var=$1&var2=$2

Perhaps you meant it only as a loose example, but without seeing your actual code, it's fairly impossible to guess what the problem is.

Jim