Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to put an environment variable in the condPattern part of a RewriteCond? Here is what i tried:

RewriteCond %{REQUEST_URI} /%{ENV:ALIAS}/(js|css|img).*
RewriteRule (.*) - [L,NS]

But this is interpreted literally by apache (it tries to match %{ENV:ALIAS} instead of the content of that environment variable.

How can i acomplish this?


share|improve this question
Can you clarify how you found that it's trying to match it literally? If you've confirmed that, you must have a rewrite log - can you share it? –  Shane Madden Feb 6 '12 at 22:58
2nd argument of RewriteCond directive should be either regex matching pattern or exact string (when lexicographical comparison is used). Variable replacement (%{VAR}) does not work there. –  LazyOne Feb 7 '12 at 1:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.