我希望所有查询都像
http://mysite.com/something/otherthing?foo=bar&x=y
改写为
http://mysite.com/something/otherthing.php?foo=bar&x=y
换句话说,只需将 .php 扩展名设置为通用的即可。
最佳答案
我会这样做。基本上,如果文件不存在,请尝试向其中添加 .php。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1.php [QSA,L]
关于php - 使用 mod_rewrite RewriteRule 重写所有查询以不需要 .php 扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/183921/