How Can I Have A Conditional .htaccess Block?

前端 未结 4 2000
说谎
说谎 2020-12-05 05:47

This is an Apache question you\'ve probably come across before. I want to have one source package that I can deploy to my workstation, my staging server, and my production s

4条回答
  •  醉话见心
    2020-12-05 05:53

    Instead of using SetEnv, use the environment variable setting capabilities of RewriteRule itself:

    RewriteCond %{HTTP_HOST} =foo.com
    RewriteRule ^ - [E=VARNAME:foo]
    
    RewriteCond %{HTTP_HOST} =bar.com
    RewriteRule ^ - [E=VARNAME:bar]
    

    Although I prefer doing this sort of thing by passing flags to the httpd process at startup and looking for them using IfDefine blocks.

    
    SetEnv VARNAME foo
    
    
    
    SetEnv VARNAME bar
    
    

提交回复
热议问题