用GET参数重写一个url

时间:2017-03-27 09:13:07

标签: php .htaccess url-rewriting

我需要用.htaccess重写规则来重写表格

中的网址

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

到表格

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

例如,我希望将网址http://localhost:8080/test/college_details.php?id=53&name=college-name重写为http://localhost:8080/test/college-name/53

1 个答案:

答案 0 :(得分:1)

在测试目录中使用以下规则。

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