Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite supports condition rewrites?

         

scorpion

4:20 pm on Oct 31, 2003 (gmt 0)

10+ Year Member



Does anybody know how to make code not go into an infinite loop such as:

.htaccess:
RewriteRule ^main\.html$ main.php [T=application/x-httpd-php] [L]

main.php:
header("Location: main.html");

Is there a way that the rewrite can know to do the rewrite to main.php ONLY once for this sequence, somehow to 'remember'?

jdMorgan

6:13 pm on Oct 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



scorpion,

If you use an external redirect - as in your script 'Location' header - then that is returned to the client browser, the browser then creates a *new* HTTP request, and the server will have no memory of the previous request. So, it will loop forever.

Perhaps you can use different names (for example, main1, main2, etc.) to accomplish what you want. Or you can use session variables, cookies, and all that stuff to track the user and control the path.

Jim