Whenever an .htaccess function requires the rewrite engine to be on, the line that performs this is always included in every code example that I ever see; but no-one ever thinks to mention whether it is necessary to repeat it for every function (which is the impression that the examples give) or just write it once at or near the beginning of the file (which I think may be the more likely situation, possibly).
Could anyone clarify how, exactly, it needs to be applied? Thanks.
(Sorry if this is old ground, but I couldn’t find the answer by searching.)
You only need to put it in the .htaccess once, before any RewriteCond and RewriteRule lines.
Doesn’t necessarily have to be the first line, the following is perfectly acceptable
What the RewriteEngine on/off statement does is to turn off/on the comment mode for mod_rewrite (RewriteEngine off starts comment mode; RewriteEngine on turns the comment mode off - using the “on” mode “merely” ensures that the comment mode hadn’t been turned on elsewhere).