views:

19

answers:

2

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.

+3  A: 

You could change

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

S.Mark
But then `/a`, `/b`, `/c`, etc. would not match.
George Edison
@George, `/a`, `/b`, `/c` will go to error.php
S.Mark
No, they would. `+` is "one or more", while `*` is zero or more.
webdestroya
Oh yeah, I forgot :) Okay, thanks then.
George Edison
A: 

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]

webdestroya