【问题标题】:Obtain url get variables when htaccess is already creating a query string当 htaccess 已经在创建查询字符串时获取 url 获取变量
【发布时间】:2014-08-18 21:48:45
【问题描述】:

我在.htaccess 中有一条规则,它根据 url 语法生成查询字符串:

RewriteEngine on
RewriteRule a_([0-9]+)_(.*).html$ article.php?id=$1 [L]

所以一个这样的网址:

a_52_how-to-use-htaccess.html 生成:article.php?id=52

我的问题是如何允许 htaccess 向查询字符串中添加其他在 url 上发送的 get 变量:

a_52_how-to-use-htaccess.html?debug=true

为了拥有:

article.php?id=52&debug=true

有什么想法吗?谢谢。

【问题讨论】:

    标签: regex apache .htaccess mod-rewrite get


    【解决方案1】:

    使用QSA 标志:

    RewriteEngine on
    RewriteRule a_([0-9]+)_(.*)\.html$ article.php?id=$1 [L,QSA]
    
    • QSA(查询字符串附加)标志在添加新参数时保留现有查询参数。

    【讨论】:

      猜你喜欢
      • 2016-12-31
      • 2014-10-18
      • 2018-09-04
      • 2023-03-17
      • 2019-01-31
      • 1970-01-01
      • 2011-06-05
      • 1970-01-01
      • 2014-11-03
      相关资源
      最近更新 更多