: Htaccess RewriteRule: Premature ending of rewrite iteration? I'm still trying to grasp the concept of Apache's RewriteRule, so please confirm if my understanding of the below is correct... So,
I'm still trying to grasp the concept of Apache's RewriteRule, so please confirm if my understanding of the below is correct...
So, here's a snippet of a website's .htaccess, I add numbers in front to ease referencing:
(1) RewriteRule ^api/rest api.php?type=rest [QSA,L]
(2) RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
(3) RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
(4) RewriteRule .* - [L,R=405]
(5) RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
(6) RewriteCond %{REQUEST_FILENAME} !-f
(7) RewriteCond %{REQUEST_FILENAME} !-d
(8) RewriteCond %{REQUEST_FILENAME} !-l
(9) RewriteRule .* index.php [L]
Now, my questions:
Doesn't rule #2 cause premature ending of Rewrite processing, because the "-" stops the iteration?
Cond #5 ~#9 are applied with 'and' logic, so rule #9 triggers only for "non-existing file/dir/links not within the /(media|skin|js)/ directories. Am I correct?
Thanks in advance!
More posts by @Sherry384
1 Comments
Sorted by latest first Latest Oldest Best
For Q1, the - doesn't mean that processing or iteration would be stopped, simply that the URL path would be passed through without any filtering or processing. The file will continue to execute rules until it reaches the end of the file or a rule is met that has the [L] last rule flag appended to it.
To clarify then,
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] would actually do no URL rewriting or rule matching but simply assign the contents of the HTTP header Authorization into an environment variable named HTTP_AUTHORIZATION.
Yes to Q2 - definately correct.
I may well be wrong here but I've never seen an error message including premature end with relation to the processing of an .htaccess file - normally this kind of error occurs when a server side script (such as your index.php) sends response text such as HTML back to the client web-browser and then tries to send some additional HTTP headers afterwards. All headers must always be sent before any content is sent.
You can read more about htaccess syntax or see examples on the Apache website.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.