What does this piece of code do? You did not explain earlier. Is it necessary for requirement 1?
- Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$
It is only required in .htaccess files and <Directory>s. This is because the mod_rewrite in them is processed at a later stage in the request processing and a new sub request is made for the file you want. If the rule matches the new request as well it will loop.
In a <VirtualHost>, a request to /pattern is matched, turned into /abc/def?type=pattern, and /abc/def is shown.
In a .htaccess file the request for /pattern is matched, turned into /abc/def?type=pattern, a new sub request is made for /abc/def?type=pattern, mod_rewrite is processed again and (if no rule matches) /abc/def is shown.
The sub request has to be made because checks like authentication have already been done by the time a .htaccess file is processed and could be different for the new sub request.
If you want to only match empty query strings, add
- Code: Select all
RewriteCond %{QUERY_STRING} ^$