简体   繁体   中英

Changing GET in url with htaccess

Basically i have http://localhost/s/item?id=1

But i want http://localhost/s/item/1

Been searching around a while but can't find a way to do this exactly, is there an easy way to accomplish this? thanks

You want to implement a rewriting rule:

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

This also means that you have to change your application logic such that it actually uses those URLs.

Such rule can be implemented in a distributed configuration file, but if possible you should prefer to place it in the actual http server's host configuration. Various reasons for that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM