Is a RewriteBase value available as a variable / reference?

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:

# all this works as I expect #
<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):

# doesn't work #
RewriteRule ^(.*)$ - [E=cache:%{RewriteBase}cache/]

, cache/ , RewriteBase. []
,, , .htaccess .
[/]

. , !

+3
2

, Apache,

#.profile of Apache user
rewritebase = "some/path"

.htaccess:

#.htaccess file
RewriteBase {$rewritebase}    
RewriteRule ^(.*)$ - [E=cache:%{ENV:rewritebase}cache]

ReWriteRule :

#This will be true for any user agent
RewriteCond  %{HTTP_USER_AGENT}  ^.*

#Replace / with / and set the rewritebase variable to /some/path
RewriteRule  /(\/some\/path)* / [E=rewritebase:$1/some/path]

#Reference the rewritebase variable
RewriteBase {$rewritebase}

#Redefine the rewritebase variable
RewriteRule ^(.*)$ - [E=rewritebase:$1]
+3

rewrite. ., . rewritebase, . rewritebase , .

RewriteRule ^index.html(/?)$ ./ [R=301,L]
+1

All Articles