Forum Moderators: phranque
I'm having trouble with endless loops using mod_rewrite. I'd be very thankful if someone can help me.
I want to redirect the following url:
[mydomain.com...]
to: [mydomain.com...]
I'm trying to do this with the following code in the .htaccess file in the catalog/bands/6/ directory:
RewriteRule ^index.php ../../../index.php?module=PostWrap&page=http://www.mydomain.com/catalog/bands/6/index.php
This creates an endless loop of redirects. Does anyone know how to redirect [example.org...] only once and then not redirect when opened by PostWrap.
Thanks in advance.
Yass
[edited by: jdMorgan at 4:06 am (utc) on Sep. 19, 2004]
[edit reason] Removed specifics per TOS [/edit]
The problem is that each redirect causes an entirely new and separate HTTP request. Since HTTP is a stateless protocol, the server cannot "remember" that previous request, and so redirects any request that matches the pattern you specify.
So the only way to prevent the redirect is to use a different URL and/or query string, and make the redirect conditional upon that.
Jim
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^index.php ../../../index.php?module=PostWrap&page=http://www.mydomain.com/catalog/bands/6/index.php [T=application/x-httpd-cgi,L]
If this is for a default page, maybe this will work. I would also throw in a [L] (last) at the end of the RewriteRule line or a [T=application/x-httpd-cgi,L]
Cheers,
Jeff