从URL&中删除.php获取请求

时间:2018-02-06 12:07:21

标签: php .htaccess url get

使用.htaccess我已经能够转换网址:
http://www.websitename.co.uk/directory/users.php?id=idValue&data2=data2Value

http://www.websitename.co.uk/directory/users?id=idValue&data2=data2Value

htaccess的:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

然而,我更愿意看到它变成了这个:
http://www.websitename.co.uk/directory/users/idValue?data2=data2Value

我希望这是有道理的,因为现在只需回显idValue,我就需要PHP方面的帮助,因为我不确定如何?

1 个答案:

答案 0 :(得分:0)

RewriteRule ^directory/users/([0-9_]+)/([A-Za-z0-9_]+)$ directory/users.php?id=$1&data2=$2 [L,QSA]

duplicate