.htaccess - SetEnvIf HTTP_HOST 不工作

标签 .htaccess apache2 setenv http-host ifdefine

我无法让它在 .htaccess 的这一部分工作,IfDefine从不运行。我做错了什么,setenvif模式已启用。

RewriteBase /

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

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

这是基于:With mod_rewrite can I specify a RewriteBase within a RewriteCond?

编辑:
有没有其他方法可以完成上述操作?

最佳答案

SetEnvIf 适用于请求 header 。所以你想使用 HOST 而不是 HTTP_HOST。例如。

SetEnvIf HOST ^localhost$ local

关于.htaccess - SetEnvIf HTTP_HOST 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9212292/

相关文章:

php - 使用 apache 的 mod_rewrite 解析 SEO 友好的 URL

php - Symfony3(或 htaccess)仅在特定的基本 url 上强制执行 HTTPS

php - 用户登录后将所有网页重定向到 HTTPS?

docker - 为什么apache2在docker image重启时不删除pid文件

php - 使用 SetEnv 或 php.ini 存储数据库变量有多安全?

.htaccess - 301 htaccess 仅限首页重定向

ruby-on-rails - 应用程序请求的 ArgumentError

php - 如何使用 php5 和 apache2 在 debian 上安装 soap.so 扩展?

C、OpenMP、更改计划类型、setenv

c - Windows 中 setenv 的等效项是什么?