大佬教程收集整理的这篇文章主要介绍了使用nginx通过index.php路由请求,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在将我的服务器从Apache迁移到Nginx并拥有这个非常简单的.htaccess规则:
RewriteENGIne On
RewriteCond %{requEST_FILename} !-f
RewriteRule ^ index.php [QSA,L]
它背后的想法是将每个请求都指向前端控制器(index.php).我正在尝试用Nginx做同样的事情.我使用在线转换器来制作这个Nginx位置块:
LOCATIOn / {
if (!-e $request_fileName){
rewrite ^(.*)$/index.php break;
}
}
但是当我将它添加到我的网站的配置时,Nginx只是下载php文件的源代码.作为参考,这是整个配置文件:
http://pastebin.com/tyKtM1iB
我知道php有效,好像我删除了位置块并使用<>php phpinfo()创建了一个文件;它工作正常. 任何帮助,将不胜感激.
LOCATIOn / {
try_files $uri $uri/ /index.php?$args; #if Doesn't exist,send it to index.php
}
LOCATIOn ~ \.php${
include fastcgi_params;
fastcgi_intercept_errors on;
# By all means use a different server for the fcgi processes if you need to
fastcgi_pass 127.0.0.1:9000;
}
例如,这些被发送到index.php:
http://foo.bar/something/
http://foo.bar/something/?something=1
虽然这些直接转到文件
http://foo.bar/someotherphp.php
http://foo.bar/assets/someimg.jpg
以上是大佬教程为你收集整理的使用nginx通过index.php路由请求全部内容,希望文章能够帮你解决使用nginx通过index.php路由请求所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。