2

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

9
  • May be the DOCUMENT_ROOT is $_SERVER['DOCUMENT_ROOT'] Commented May 22, 2016 at 8:39
  • also you can try with $_SERVER['SERVER_NAME']. Commented May 22, 2016 at 8:40
  • @FrayneKonok the question is: how concatenate environment variable in htaccess... Commented May 22, 2016 at 8:40
  • Did you try this?? SetEnv SpecialPath $_SERVER['DOCUMENT_ROOT']."/dir/" Commented May 22, 2016 at 8:46
  • @FrayneKonok yes... not work... same problem. Commented May 22, 2016 at 8:48

1 Answer 1

4

%{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]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.