【问题标题】:Allow .htaccess RewriteCond redirect exception允许 .htaccess RewriteCond 重定向异常
【发布时间】:2013-09-23 22:53:31
【问题描述】:

这是我当前的 .htaccess 文件的表示,我用它来代理内部服务:

RewriteEngine On
RewriteRule (.*)admin(.*) https://some/path/forbidden.html [L,R=301]
RewriteRule uri1/(.*)$ http://localhost:30000/$1 [P]
RewriteRule uri2/(.*)$ http://localhost:30001/$1 [P]

效果很好,但我想允许“admin/reset”出现单个异常,但在包含“admin”的任何其他 uri 上继续执行 301。我该怎么做?

【问题讨论】:

  • admin(?!/reset) - 这称为前瞻。

标签: apache .htaccess http redirect mod-rewrite


【解决方案1】:

你可以使用条件:

RewriteCond %{REQUEST_URI} !admin/reset
RewriteRule (.*)admin(.*) https://some/path/forbidden.html [L,R=301]

【讨论】:

    猜你喜欢
    • 2013-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-19
    • 2014-08-11
    • 2021-02-08
    • 1970-01-01
    • 2015-05-30
    相关资源
    最近更新 更多