Open kajman-cz opened 2 years ago
@kajman-cz thanks for creating this issue. Do you have a practical example where this behavior introduces bugs in the htaccess tester? That would help us understand the exact problem a bit better and to implement improvements to the tool.
Sorry for bad link to example. I edited first post and repair is. The link is now https://htaccess.madewithlove.com/?share=af2c2630-8373-46bf-a809-71a26ecb791f
There are steps
RewriteEngine On RewriteEngine was now turned on for the document.
RewriteCond %{QUERY_STRING} ^qs$ This condition was not met.
RewriteRule ^index.html$ - [L] This rule was not met.
But apache tests pattern in RewriteRule before your step 2. Apache log (how to enable it): [perdir D:/data/dev/www/example/] strip per-dir prefix: D:/data/dev/www/example/index.html -> index.html [perdir D:/data/dev/www/example/] applying pattern '^index\.html$' to uri 'index.html' [perdir D:/data/dev/www/example/] RewriteCond: input='' pattern='^qs$' => not-matched [perdir D:/data/dev/www/example/] pass through D:/data/dev/www/example/index.html
In Debugging info is RewriteCond before RewriteRule, but the Apache first evaluates the first parameter (pattern) in the RewriteRule and only on match begins to test the conditions in the RewriteCond written before that RewriteRule.
The example lacks pattern testing between steps 1 (RewriteEngine On) and 2 (RewriteCond %{QUERY_STRING} ^qs$).
Manual says: _The rewriting engine loops through the ruleset rule by rule (RewriteRule directives) and when a particular rule matches it optionally loops through existing corresponding conditions (RewriteCond directives). For historical reasons the conditions are given first, and so the control flow is a little bit long-winded._ https://httpd.apache.org/docs/current/rewrite/tech.html#InternalRuleset