Nathan Osman
Nathan Osman

Reputation: 73195

How come the [L] flag isn't working in my .htaccess file?

Here are the rules:

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteRule ^$ index.php?action=home [L]
RewriteRule ^[\w\W]*$ error.php [L]

When a page matches the first one, it is supposed to ignore any other further rules. Yet accessing / results in error.php being invoked. Commenting out the second rule works as intended - the page redirects to index.php.

What am I doing wrong?

Also: is there a better way to write the last line? It's basically a catch-all.

Upvotes: 1

Views: 138

Answers (2)

Mitch Dempsey
Mitch Dempsey

Reputation: 39899

If the last line is a catch-all, just do RewriteRule ^.*$ error.php [L]

Your first line might be erroring out when you send a request for / because your rule is saying "nothing" and you are sending /.

Try changing your rule to RewriteRule ^/$ index.php?action=home [L]

Upvotes: 0

YOU
YOU

Reputation: 123841

You could change

^[\w\W]*$ to ^[\w\W]+$ or ^.+$

Upvotes: 3

Related Questions