【问题标题】:add parameters to get in when mod_rewrite is already there当 mod_rewrite 已经存在时添加参数以进入
【发布时间】:2022-02-19 15:54:03
【问题描述】:

我想在链接中使用 htaccess 中的此规则处理的链接中的 href 标记传递一个附加参数

 RewriteEngine On
 RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
 RewriteRule .* . [F,L]
 RewriteBase /

 RewriteRule ^([^/]+)/contact.html         contact.php?ln=$1 [L]

我想使用的链接是这个

/en/contact.html?t=Build 5

然后到页面应该contact.php?ln=en&t=Build 5。

如果我在 contac.php 中打印,$ _GET 只返回 ln = en。

我该怎么办?

【问题讨论】:

  • 旁白: /en/contact.html?t=Build 5 - 您应该对 URL 参数值进行 URL 编码。 IE。 空格应该在查询字符串中编码为%20或+。

标签: php html apache .htaccess hyperlink


【解决方案1】:

您必须在规则中使用[L,QSA],才能获取您的参数。

RewriteRule ^([^/]+)/contact.html         contact.php?ln=$1 [L,QSA]

见[QSA] (QueryStringAppend)

【讨论】:

  • 感谢您的建议已解决。谢谢
猜你喜欢
  • 2023-03-29
  • 2013-06-08
  • 1970-01-01
  • 2023-03-03
  • 1970-01-01
  • 1970-01-01
  • 2016-05-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多