I am writing a .htaccess file that checks if the requested page exists in the cache or not. To perform the check (and save the input), I set the ENV variable with the cache location:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /some/path/
RewriteRule ^(.*)$ - [E=rewritebase:/some/path/,E=cache:%{ENV:rewritebase}cache/]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{ENV:cache}$1\.html -f
RewriteRule ^(.*)$ $1\.html [L]
</IfModule>
As you can see, I also need to set the ENV variable to get up for the RewriteBase value. I would prefer, because if the RewriteBase is changed, I will also need to remember the ENV variable. In the end, it can be part of the CMS used by others, which I would like to make as simple and simple as possible, with minimal potential for error. I would like to be able to set only a variable ENV:cachewithout having to set a variable ENV:rewritebase, for example (or similar):
RewriteRule ^(.*)$ - [E=cache:%{RewriteBase}cache/]
, cache/ , RewriteBase.
[]
,, , .htaccess .
[/]
. , !