【问题标题】:HTACCESS friendly url and allow GET methodHTACCESS 友好的 url 并允许 GET 方法
【发布时间】:2014-06-28 07:49:04
【问题描述】:

我的代码是

 Options -Multiviews

 RewriteEngine On
 RewriteBase /

 RewriteRule ^([a-z0-9-]+)\.html$ /index.php?cat=$1 [L]

如果我访问

mysite.com/name-of-category.html 

它有效,但如果我访问

mysite.com/name-of-category.html?anything=something

它显示了网页,但$_GET["anything"] 没有显示任何内容。

【问题讨论】:

    标签: php apache .htaccess url seo


    【解决方案1】:

    你必须指定一个名为QSA or 'Query String Append'的选项:

    RewriteRule ^([a-z0-9-]+)\.html$ /index.php?cat=$1 [L,QSA]
    

    它将确保原始查询字符串也包含在您的新 URL 中。

    【讨论】:

    • 非常感谢@Answerer!
    • 请注意,标志 [L, QSA] 之间没有空格将起作用 :) (答案正确 - [L,QSA] 之间没有空格)
    猜你喜欢
    • 1970-01-01
    • 2019-01-06
    • 1970-01-01
    • 2012-06-23
    • 1970-01-01
    • 2013-08-31
    • 2012-06-03
    • 2015-12-16
    相关资源
    最近更新 更多