【问题标题】:How point multiple directories in htaccess using if else condition in htaccess?如何使用 htaccess 中的 if else 条件在 htaccess 中指向多个目录?
【发布时间】:2010-11-13 06:30:01
【问题描述】:

我想使用 htaccess 指向多个目录。

假设我有两个目录 AAA 和 BBB。

如果(在 url "AAA" 中存在)指向目录 AAA; else 指向目录 BBB。

有可能吗??

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    这是你的意思吗?

    # make sure mod_rewrite is on
    RewriteEngine On
    
    # check request URI for AAA and rewrite to /AAA/ (only once)
    RewriteCond %{REQUEST_URI} !^/AAA.*
    RewriteRule (.*)           /AAA/$1   [L]
    
    # otherwise rewrite to /BBB/
    RewriteRule (.*)           /BBB/$1
    

    另外,你可能想试试:

    RewriteCond %{REQUEST_URI} ^[^A]+AAA.*
    

    而不是第一行,因为我不记得他们是否是RewriteRules 前面的/...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-19
      • 2017-08-25
      • 2019-04-25
      • 1970-01-01
      • 2015-04-29
      • 1970-01-01
      • 2011-01-18
      • 2016-03-23
      相关资源
      最近更新 更多