使用mod_rewrite RewriteRule将所有查询重写为不需要.php扩展名 [英] Rewrite all queries to not need the .php extension using a mod_rewrite RewriteRule
本文介绍了使用mod_rewrite RewriteRule将所有查询重写为不需要.php扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望所有查询
http://mysite.com/something/otherthing?foo=bar&x=y
被改写为
http://mysite.com/something/otherthing.php?foo=bar&x=y
换句话说,只需将.php扩展名设为通用即可.
In other words, just make the .php extension optional, universally.
推荐答案
我会这样做.基本上,如果文件不存在,请尝试向其中添加.php.
I would do it this way. Basically, if file doesn't exist, try adding .php to it.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1.php [QSA,L]
这篇关于使用mod_rewrite RewriteRule将所有查询重写为不需要.php扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文