使用带有两个以上GET变量的.htaccess在PHP中重写URL

时间:2017-04-18 10:07:30

标签: php .htaccess url-rewriting getparameter

我的网址是:

 http://example.com/demo/my_list.php?id=122&name=test files

万万要把它变成:

 http://example.com/demo/my_list.php/test files/122

目前我的htaccess如下:

 RewriteEngine on

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^([^/]+)$ index.php?id=$1 [L]

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^([^/]+)/([^/]+)$ my_list.php?id=$1&name=$2 [L]

但它不起作用......

如何用两个以上的GET变量重写php中的url?

我放置了我的htaccess文件?在' demo'里面文件夹或根路径?

请任何人帮忙......

1 个答案:

答案 0 :(得分:0)

像这样使用,

RewriteRule ^my_list\.php/([^/]+)/([^/]+)$ my_list.php?id=$2&name=$1 [L]