I have an issue that is confusing me. I have two rules in my .htaccess file where one should handle requests for one url path and another that would check it again for another path. The second rule is more general than the first. I am expecting the first to catch its instances and the [L] to halt rule processing, but everything is falling through to the second rule and getting directed to the wrong page. Shouldn’t the first rule be applied where applicable and then rule processing halt?
Here are the two rules as they appear:
## Path 1 ##
RewriteCond %{REQUEST_URI} ^directory/.*-([0-9]+)/?$
RewriteRule ^directory/.*-([0-9]+)/?$ directory/page.php?id=$1 [L]
## Path 2 ##
RewriteCond %{REQUEST_URI} ^.*-([0-9]+)/?$
RewriteRule ^.*-([0-9]+)/$ page.php?id=$1 [L]
Maybe I’m missing something obvious, but as I understood things, the first rule (if conditions were met) would be applied and then the rule processing would stop.
Any help would be greatly appreciated.
Thank you
You actually do not need the
RewriteConddirectives, as theRewriteRulepatterns already imply them. This works in my tests:If for some reason you still need the
RewriteConddirectives, keep in mind that%{REQUEST_URI}actually starts with a slash, and you must match for it.