Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite question

         

Yass

11:23 pm on Sep 18, 2004 (gmt 0)

10+ Year Member



Hello,

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]

jdMorgan

4:11 am on Sep 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to try creating an "alias" URL for index.php. Otherwise, there is no way to prevent the redirection loop with your current set-up.

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

Yass

8:27 pm on Sep 19, 2004 (gmt 0)

10+ Year Member



Thank you so much for the help. I guess I'll have to structure my site differently

hiker_jjw

11:51 pm on Sep 20, 2004 (gmt 0)



What about just throwing in a query string condition.

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