【问题标题】:htaccess, If subdomain is not "dev" follow these instructionshtaccess,如果子域不是“dev”,请按照以下说明操作
【发布时间】:2020-05-25 14:23:27
【问题描述】:

我怎样才能做到正确? 如果子域不是“dev”,请按照这些说明操作

RewriteEngine On
Options +MultiViews
Options +FollowSymlinks

# -----------------%<-----------------
# If subdomain is not "dev"
RewriteCond %{HTTP_HOST} !^dev\.*
# follow these instructions
AddHandler fcgid-script .php
MultiviewsMatch Handlers Filters
# -----------------%<-----------------

【问题讨论】:

  • 通过检查正确环境变量的内容——%{HTTPS}显然不是。你要查%{HTTP_HOST}
  • 我自己开了处方。现在它在 HTTP_HOST 上

标签: .htaccess addhandler


【解决方案1】:

这不是你应该在分布式配置文件(“.htaccess”)中配置的东西,这不是那些文件的用途。相反,这应该在一个单独的虚拟主机中实现,您根本不需要条件。

RewriteCond 是重写模块的一部分,您不能以某种方式将它与其他模块的指令结合使用。

您可以尝试类似的方法,但如前所述,我建议您不要这样做:

<If "%{HTTP_HOST} == 'dev.example.com'">
    AddHandler fcgid-script .php
    MultiviewsMatch Handlers Filters
</If>

您可以在此处找到文档: https://httpd.apache.org/docs/2.4/expr.html#examples

【讨论】:

    猜你喜欢
    • 2011-04-11
    • 2016-03-31
    • 2012-03-03
    • 2016-05-19
    • 2013-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多