用htaccess修改url中的GET



基本上我有http://localhost/s/item?id=1

但是我想要http://localhost/s/item/1

一直在寻找一段时间,但无法找到一种方法来做到这一点,有一个简单的方法来完成这一点吗?由于

您想要实现一个重写规则:

RewriteEngine on
RewriteRule ^/?s/item/(d+)$ /s/item?id=$1 [QSA,END]

这也意味着您必须更改应用程序逻辑,以便它实际使用这些url。

这样的规则可以在分布式配置文件中实现,但如果可能的话,您应该将其放在实际的http服务器的主机配置中。原因有很多。

最新更新