1

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.

Gumbo
  • 620,600
  • 104
  • 758
  • 828
Nathan Osman
  • 67,908
  • 69
  • 250
  • 347
  • I need the last rule to take effect **only if the other rules did not match**. – Nathan Osman May 11 '10 at 03:52
  • 1
    Maybe cause `within the .htaccess context, [L] will not force mod_rewrite to stop` see http://stackoverflow.com/questions/286004/hidden-features-of-mod-rewrite/286005#286005 – Marco Demaio Apr 07 '11 at 13:50

2 Answers2

3

You could change

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

YOU
  • 114,140
  • 31
  • 183
  • 213
0

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]

Mitch Dempsey
  • 36,881
  • 6
  • 65
  • 73