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开发者_如何学C [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.
You could change
^[\w\W]*$
to ^[\w\W]+$
or ^.+$
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]
精彩评论