Replace URL query string with slash for a friendly

2019-01-29 04:32发布

问题:

I use the following query string

?eve=MTkzODMwMjk0OQ==

to change the content of the node's body according to the value of the value of eve.

The full URL looks like this:

http://localhost/party/event.php?eve=MTkzODMwMjk0OQ== I would like to clean up the url to look like this instead:

http://localhost/party/event.php/eve/MTkzODMwMjk0OQ==

How can I do this with ?

回答1:

You can even omit .php to make it more clean

Options +FollowSymLinks
RewriteEngine on
RewriteRule event/eve/(.*)/ event.php?eve=$1
RewriteRule event/eve/(.*) event.php?eve=$

Example URL

  http://localhost/party/event/eve/MTkzODMwMjk0OQ/ 

will transfer to

  http://localhost/party/event.php?eve=MTkzODMwMjk0OQ==