【问题标题】:htaccess redirect using OR and NChtaccess 使用 OR 和 NC 重定向
【发布时间】:2011-10-18 13:59:57
【问题描述】:

我想知道是否可以在我拥有域的地方执行此重定向:example.com 与 IP 的 or 语句一起不区分大小写。两者相互独立但不能一起工作?

RewriteCond %{HTTP_HOST} ^example\.com [OR] [NC] RewriteCond %{HTTP_HOST} ^123\.45\.67\.89 重写规则 (.*) http://www.example.com/$1 [R=301,L]

【问题讨论】:

    标签: apache .htaccess redirect case case-sensitive


    【解决方案1】:

    标志应该一起列出,用逗号分隔 -- 与 RewriteRule 本身的方式完全相同:

    RewriteCond %{HTTP_HOST} ^example\.com [OR,NC]
    RewriteCond %{HTTP_HOST} ^123\.45\.67\.89
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    

    另一种方法:

    RewriteCond %{HTTP_HOST} ^(example\.com|123\.45\.67\.89) [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2018-03-12
      • 2015-03-20
      • 2017-06-16
      • 2013-12-30
      • 2010-10-19
      • 2011-03-01
      相关资源
      最近更新 更多