使用 QSA 的 HTAccess mod 重写问题
我想向 URL 添加参数,但目前它没有显示在 $_GET 全局中。 我的 htaccess 文件中的片段如下:
RewriteRule ^account/blogs/([0-9]+)/([^\s?]+)/?$ /account/blog.php?blogId=$1 [L,QSA]
然后在我的 php 代码中我想添加一个链接,例如:
/account/blogs/1/ThisIsWhereTheTitleGoes?delete=1
通配符(除空格外的任何字符)选项用于博客标题,因为我永远不知道它会是什么。我知道要在末尾添加一个查询字符串参数,例如 ?delete=1。然而我不希望这是重写的一部分。
有谁知道如何做到这一点? 谢谢
I want to add a parameter to a URL but currently it isnt showing in the $_GET global.
A snippet from my htaccess file is as below:
RewriteRule ^account/blogs/([0-9]+)/([^\s?]+)/?$ /account/blog.php?blogId=$1 [L,QSA]
Then in my php code i want to add a link such as:
/account/blogs/1/ThisIsWhereTheTitleGoes?delete=1
The wildcard (any char but space) option is for the blog title as i never know what it would be. I know want to add a query string param on the end such as ?delete=1. I however dont want this as part of the rewrite.
Does anybody know how to so this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最好的选择是简单地将 get 变量添加到正则表达式中,如下所示:
这将重写
为
它也将支持其他变量。
My best bet would be to simply add get variables to the regex, like so:
This would rewrite
to
It would also support additional variables.