【问题标题】:apache rewrite with proxy flag doesn't work with similar nameapache rewrite with proxy flag 不适用于类似名称
【发布时间】:2020-11-06 14:28:12
【问题描述】:

我的站点中有/my-page.html/hello/my-page.php,调用my-page.html 时我必须从my-page.php 获取内容。

我在下面写了一些东西,这是错误的。

RewriteRule "my-page.html" "/hello/my-page.php" [P]

但是当我更改名称时它会起作用。

RewriteRule "my-somethingelse" "/hello/my-page.php" [P]

知道如何使用相同的名称吗?

【问题讨论】:

    标签: regex apache mod-rewrite url-rewriting mod-proxy


    【解决方案1】:

    这里不需要使用P(代理)标志。你可以使用L

    您似乎还启用了 MultiViews 选项,您可以在 .htaccess 顶部使用此行禁用:

    Options -MultiViews
    

    和规则:

    RewriteRule ^/?my-page\.html$ /hello/my-page.php [L,NC]
    

    【讨论】:

    • 不,我想继续下一个规则,然后只有它提供准确的数据。这就是我使用代理的原因
    • L 不会停止进一步的规则处理。请测试一下,看看是否有效。
    • 如果您有mod_proxy 设置,那么您也可以随意使用RewriteRule ^/?my-page\.html$ /hello/my-page.php [P,NC]
    • 抱歉不工作 :( 得到 404 只有当我将名字更改为与第二部分不同的名字时它才会工作
    • 您能否发布完整的 .htaccess 文件
    猜你喜欢
    • 2012-02-18
    • 1970-01-01
    • 1970-01-01
    • 2016-07-17
    • 2014-06-04
    • 2020-08-20
    • 1970-01-01
    • 2018-07-21
    • 2011-07-13
    相关资源
    最近更新 更多