【问题标题】:rewrite url and let more parameters重写url,让更多参数
【发布时间】:2013-02-18 12:29:47
【问题描述】:

我正在重写这种网址

http://deia.info/category/calendar/10/

/index.php?task=browse_posts&catid=$2

通过.htaccess中的这段代码

RewriteRule ^category/(.+)/(.+) /index.php?task=browse_posts&catid=$2

这似乎可以完成这项工作。问题是在发送附加参数时,这些参数会被忽略。

例如:

http://deia.info/category/calendar/10/?start_date=10

isset($_GET['start_date']) 不会返回 true

为什么?

【问题讨论】:

  • 添加到重写规则 [L,QSA] 看看会发生什么。
  • 有效!如果你想。将其发布为答案:-)
  • 当然。我现在就去做。

标签: php .htaccess url-rewriting get


【解决方案1】:

当传入的 URL 包含类似 OP 示例中的查询时:

http://deia.info/category/calendar/10/?start_date=10

在替换 URL 中将其与/附加到新查询的方法是添加 QSA Flag

所以添加[L,QSA],像这样:

RewriteRule ^category/(.+)/(.+) /index.php?task=browse_posts&catid=$2 [L,QSA]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-19
    • 1970-01-01
    • 1970-01-01
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 2017-02-03
    • 2016-07-29
    相关资源
    最近更新 更多