【问题标题】:.htaccess rewrite pretty urls that can still use get variables.htaccess 重写仍然可以使用 get 变量的漂亮 url
【发布时间】:2013-02-16 09:11:07
【问题描述】:

我正在尝试编写一个 .htaccess 行,该行将重写为 php 脚本,但仍允许在最后添加任何额外的 get 变量。这可能吗?

目前我正在尝试使用这个:

RewriteRule ^item/([^/]*)([^/]*)$ /item.php?id=$1&$2 [L]

目标是能够做到blah.com/item/fooblah.com/item/foo?bar=whatever 之类的事情。

目前它似乎正确地通过了第一部分id,但没有通过其余部分。

【问题讨论】:

标签: apache .htaccess url get


【解决方案1】:
RewriteRule ^item/([^/]*)([^/]*)$ /item.php?id=$1&$2 [L,QSA]

您可以在此处阅读有关QSA(查询字符串附加)的更多信息: https://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

【讨论】:

    【解决方案2】:

    你需要以[L,QSA]结束

    【讨论】:

      猜你喜欢
      • 2016-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多