【问题标题】:RewriteRule with query string gets rewritten to /param/param/带有查询字符串的 RewriteRule 被重写为 /param/param/
【发布时间】:2015-01-16 14:26:54
【问题描述】:

我有这个重写:

RewriteRule ^gallery/([^/]+)/?$ /gallery.php?title=$1 [L]

但是,当导航到 gallery/a/ 时,内部重定向是:

gallery.php/a //(instead of: gallery.php?title=a)

什么会导致这种行为?

【问题讨论】:

    标签: apache .htaccess mod-rewrite rewrite webmin


    【解决方案1】:

    选项MultiViews 可能是这里的罪魁祸首。选项MultiViewsApache's content negotiation module 使用,该选项在mod_rewrite 之前运行,并使Apache 服务器匹配文件的扩展名。所以/file 可以在 URL 中,但它会服务于/file.php

    使用 .htaccess 顶部的这一行将其关闭:

    Options -MultiViews
    

    【讨论】:

    • 太棒了,就是这样!
    猜你喜欢
    • 1970-01-01
    • 2023-04-04
    • 2015-05-27
    • 2014-11-04
    • 2013-12-21
    • 1970-01-01
    • 1970-01-01
    • 2015-08-08
    • 1970-01-01
    相关资源
    最近更新 更多