.htaccess删除扩展,同时保留uri参数


.htaccess remove extension while preserving uri parameters



我试图用一种友好的方式重写我的url;我已经编写了所有的php代码来处理所有的事情
我唯一不能做的就是删除.php扩展,同时保留uri参数
因此,从本质上讲,我正在寻找一些.htaccess规则来改变:

www.example.com/biography.php/john-doe

到此:

www.example.com/biography/john-doe

(johndoe不是一个真正的文件,它只是传递给传记.php的GET参数)

谢谢大家

如果你网站上的链接已经像这个

www.example.com/biology/john-doe

你想在服务器上处理它们,就像这个

www.example.com/biology.php/john-doe

将以下内容添加到站点根目录中的.htaccess文件中。

RewriteEngine on
RewriteBase /
RewriteRule ^([-a-zA-Z]+)/([-a-zA-Z]+)$ $1.php/$2 [L]

应该做:

RewriteRule ([^'.]).php(.*) $1$2 [QSA,R=301]