nginx去掉“.php”的方法:首先找到并打开nginx相应文件;然后修改代码为“location / {try_files $uri $uri/ $uri.php?$args;}”;最后保存该文件即可。
nginx rewrite 隐藏.php后缀
我想实现http://xxx测试数据/post/abc.php隐藏后缀的效果,即:http://xxx测试数据/post/abc,网上搜了一大堆都只是隐藏index.php重定向到入口文件,这个谁不会啊,但这不是我想要的。然后有的说nginx不行,只能用apache,然而我只轻轻的改了改,一切就是那么的如丝搬顺滑,正是我要的效果!
其实很简单,一行代码的事情
location / { try_files $uri $uri/ $uri.php?$args; }现在下面两组url的访问效果是一样的
before: http://abc测试数据/login.php http://abc测试数据/register.php http://abc测试数据/blog/post.php http://abc测试数据/xxx/xxx/anything.php after: http://abc测试数据/login http://abc测试数据/register http://abc测试数据/blog/post http://abc测试数据/xxx/xxx/anything推荐:《PHP教程》
以上就是nginx怎么去掉.php后缀的详细内容!
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did55374
nginx怎么去掉.php后缀
阅读:47次