简体   繁体   中英

How to change a URL parameter to /parameter

I have a URL that looks like this: https://www.example.com/users.php?username=Name . Instead of this I want it to look like this: https://www.example.com/users/username=Name . What are the steps to aquire this? I have tried searching, but I just cannot figure out what to search to find the answer.

It depends if you're using an apache server you can acquire this with .htaccess, in that case you could use RewriteEngine On with the specific RewriteRule.

.htaccess file in the root of you're website/domain:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^users/username=(.*)$ /users.php?username=$1

Beside this there are a lot of more options and flags with htaccess rewriterule

If you're using nginx it will be done on the nginx way, you may use an converter from htaccess to nginx of fins some more information for nginx rewrite url.

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