Reputation: 9034
I know .htaccess rules are parsed top to bottom but what if my URL matches two rules which one will be used and why?
I have simple rules like
^(.*)$ index.php?pag=cms&title=$1
^store/(.*)$ index.php?pag=store&id=$1
Basically any URL will match the first rule so what happens with other ones?
Upvotes: 1
Views: 4591
Reputation: 51711
If the URL matches two rules, it's the first one that rewrites. This is not to say that the second rule doesn't fire. It does but it fails to match because subsequent rules fire on the output of the rule preceding it.
If somehow you don't want the rewrite to fall-through and stop at the first matching rule you can mark the rule as last by using the [L]
flag.
^(.*)$ index.php?pag=cms&title=$1 [L]
^store/(.*)$ index.php?pag=store&id=$1 # won't fire now
Upvotes: 6