简体   繁体   中英

rewrite an url with GET parameters

What rewrite rule in .htaccess do I need to rewrite an url in the form

http://localhost:8080/test/college_details.php?id=[some id]&name=[some name]

to the form

http://localhost:8080/test/[some name]/[some id]

For example, I'd like the URL http://localhost:8080/test/college_details.php?id=53&name=college-name to be rewritten to http://localhost:8080/test/college-name/53

Use below rule in test directory.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/([\d]+)$ college_details.php?id=$2&name=$1 [QSA,L]

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