【问题标题】:How do not redirect to /public_html if request is equaled /abc/* for example?例如,如果请求等于 /abc/*,如何不重定向到 /public_html?
【发布时间】:2014-08-18 13:19:18
【问题描述】:

有这样一种目录结构:

/public_html
/abc
.htaccess

现在所有请求都转到文件夹 /public_html。这是.htaccess的代码:

RewriteEngine on

RewriteCond %{REQUEST_URI} !public_html/
RewriteRule (.*) /public_html/$1 [L]

如果[the website address]/abc/* 等请求重定向到文件夹 /abc 而不是 /public_html,我应该怎么做?

类似的东西:

example.com/* - 转到 /public_html

example.com/abc/* - 转到 /abc

谢谢!我很抱歉我的英语不好!

【问题讨论】:

    标签: .htaccess redirect subdirectory public-html


    【解决方案1】:
    RewriteCond %{REQUEST_URI} !public_html/
    

    表示如果 REQUEST_URI 不包含public_html/,则要重写。因此,为了确保您没有使用abc/ 重写 URI,您需要另一个条件,即添加

    RewriteCond %{REQUEST_URI} !abc/
    

    在第一次 RewriteCond 之后,它应该可以工作。现在你说如果它不包含 abc/ 或 public_html/ 重写 url。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-30
      • 2021-03-28
      • 1970-01-01
      • 2015-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多