httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexis Huxley <ahux...@gmx.net>
Subject [users@httpd] Re: mod_rewrite tricky problem
Date Fri, 23 Apr 2004 09:38:48 GMT
> These types of problems are solved by activating the RewriteLog and seeing
> what is actually going on.

Thanks! That helped, it lead me to do a Google search for
'internal redirect' and that turned up the following in message
<1w0rpxy72rrqandparker@news.perlig.de> in which 
André Malo <auch-ich-m@g-kein-spam.com> says:

	RewriteEngine On
	RewriteRule 1 /2.html [L,E=FOO:1]
	RewriteCond %{ENV:REDIRECT_FOO} !=1
	RewriteRule 2 /3.html

which explains how make [L] do what one would really expect it to do 
(and stops '2' from being turned into '3' after '1' has been
turned into '2').

(Note Google stripped the underscore when it shouldn't have done I
believe, but the above is correct and tested.)

That in turn helped me get to this:

	RewriteRule    ^((?!STABLE/).*)$  STABLE/$1 [L,E=FOO:1]
	RewriteCond    %{ENV:REDIRECT_FOO} !=1
	RewriteRule    ^STABLE/(.*)$  $1 [R=permanent]

The setting of the env variable 'FOO' (available as 'REDIRECT_FOO'
after the internal redirect caused by the 'L') prevents the second
rule being applied after the internal redirect causes the rules to be
rerun (yes, rules are re-run despite 'L' in .htaccess context). And
this in means that second time round, no rules are applied and
this (i.e. getting through all rules without any application)
in turn means that no further internal redirects are caused, and
therefore the infinite loop (which was what was happening earlier)
is prevented. Blimey ...

Thanks again!

Alexis

Just for Googlers: this is a solution to remove a directory from
a URL, while actually *keeping* the files in that directory.
more keywords: mod_rewrite, last.



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message