Jesse
Jesse

Reputation: 479

RewriteRule Last flag being ignored

I don't get that if a rewrite rule matches and it has the Last [L] flag that it still executes the rules beneath. I redirect all calls to the public folder but I've added an exception for images, but the exception is being ignored. I thought that with the [L] flag if a rule matches it stops looking for rules beneath.

This is my .htaccess file:

RewriteRule ^image/(.*)/?$ image.php?t=$1 [L]

RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

If I remove the bottom 2 rules it does work.

Thanks in advance

Upvotes: 1

Views: 668

Answers (1)

akond
akond

Reputation: 16035

It is not ignored. It is the specific of .htaccess. It reruns every time URL is changed.

Try this instead.

RewriteEngine on

RewriteCond %{QUERY_STRING} rewritten
RewriteRule .* - [L]

RewriteRule ^image/(.*)/?$ image.php?t=$1&rewritten=1 [L,QSA]
RewriteRule ^$ public/?rewritten=1 [L,QSA]
RewriteRule (.*) public/$1?rewritten=1 [L,QSA]

Upvotes: 3

Related Questions