mod_rewrite query string

爱⌒轻易说出口 提交于 2019-12-25 08:04:02

问题


I have a query string like

search.php?id=12&keyword=abc&api=gIUTG6898

And I want the URL to be like this:

search/?id=12&keyword=abc&api=gIUTG6898

Now I found a lot of solutions but they are limited to only one variable in the query string. Thanks in advance


回答1:


It's not that complicated, since you just want to 'transfer' the query string. You can ignore it in the RewriteRule.

RewriteRule ^search/?$ search.php [QSA]

This just rewrites 'search/' to 'search.php'.




回答2:


Since you are wanting to remove the .php and replace it with a slash, you'd need to reverse Floern's RewriteRule somewhat:

RewriteRule ^/search.php$ /search/ [QSA,L]


来源:https://stackoverflow.com/questions/10643705/mod-rewrite-query-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!