SetEnvIf HTTP_HOST not working

Alex picture Alex · Feb 9, 2012 · Viewed 17.9k times · Source

I can't get it work this part of .htaccess, the IfDefine never runs. What am I doing wrong, setenvif mod is enabled.

RewriteBase /

SetEnvIf HTTP_HOST ^localhost$ local
<IfDefine local>
  RewriteBase /codeigniter-app/
</IfDefine>

SetEnvIf HTTP_HOST ^testing.alex.com$ testing
<IfDefine testing>
    RewriteBase /app/
</IfDefine>

This is based on: With mod_rewrite can I specify a RewriteBase within a RewriteCond?

Edit: Any other way to accomplish the above?

Answer

emarref picture emarref · Feb 29, 2012

SetEnvIf works on request headers. So you want to use HOST not HTTP_HOST. E.g.

SetEnvIf HOST ^localhost$ local