Simone Nigro
Simone Nigro

Reputation: 4887

Apache htaccess SetEnv: how concatenate environment variable in htaccess?

I want set some environment variable like this, eg.:

SetEnv SpecialPath "%{DOCUMENT_ROOT}/dir/"

but if i print SpecialPath in path PHP, eg.:

$_SERVER['SpecialPath'];

the output is

%{DOCUMENT_ROOT}/dir/

the expected output is:

/var/www/dir/

the question is: how concatenate environment variable in htaccess?

env_module is enabled

Upvotes: 2

Views: 1624

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

%{DOCUMENT_ROOT} variable is part of mod-rewrite so You can set env for a document root using SETenv directive, try this mod-rewrite based example :

RewriteEngine on


RewriteRule ^ - [E=SpecialPath:%{DOCUMENT_ROOT}/dir/,L]

Upvotes: 4

Related Questions