开发者

HTAccess mod rewrite issue using QSA

开发者 https://www.devze.com 2022-12-25 09:22 出处:网络
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:

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 开发者_StackOverflowmy 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


My best bet would be to simply add get variables to the regex, like so:

RewriteRule ^account/blogs/([0-9]+)/([^\s?]+)/?(\?(.*))?$ /account/blog.php?blogId=$1&$4 [L,QSA]

This would rewrite

/account/blogs/1/ThisIsWhereTheTitleGoes?delete=1

to

/account/blog.php?blogId=1&delete=1

It would also support additional variables.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号