nginx要怎么配置rewrite才能运行vephp、yii和thinkphp等MVC框架?
《nginx要怎么配置rewrite才能运行vephp、yii和thinkphp等MVC框架?》要点: 网络上很多配置nginx的rewrite其实是不可用的,如果想运行vephp、yii、thinkphp等MVC框架,在apache下是很容易的,nginx比较麻烦。 下面这个配置是已应用于vephp框架( www.jb51.cc ),并且对thinkphp也是可用的。并且window和linux通用,只是要把根目录替换一下。 它的原理是:如果服务器上存在该脚本文件就直接访问,如果不存在,则使用MVC框架路由解析。 特分享出来。 server { listen 80; server_name www.jb51.cc;
#charset koi8-r; #access_log logs/host.access.log main; #root /var/www/website; # linux下根目录 root M:/www/website; #window下根目录 index index.html index.htm index.php;
location ~ .(css|js|jpg|jpeg|png|bmp|gif|svg|ttf|woff|woff2|eot|otf|ico|css.map|min.map)(.*)$ { break; }
location / { #index index.htm index.html index.php; #访问路径的文件不存在则重写URL转交给框架处理 if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } }
location ~ .php/?.*$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #加载Nginx默认"服务器环境变量"配置 #include fastcgi.conf; include fastcgi_params;
#设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量 set $fastcgi_script_name2 $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+.php)(/.+)$") { set $fastcgi_script_name2 $1; set $path_info $2; } fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2; fastcgi_param SCRIPT_NAME $fastcgi_script_name2; }
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html #error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }
# deny access to .htaccess files,if Apache's document root # concurs with nginx's one # location ~ /.ht { deny all; }
} 如果是apache配置rewrite,则参考这里http://www.jb51.cc/jiaocheng/20.html (编辑:岳阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 获取视频文件的实际时间,以便使用nginx_mod_h264_streaming
- php – 使用nginx的混合IP和基于名称的虚拟主机
- nginx – Lighttpd的内存泄漏,一个神话还是真的?如果为tru
- 在Nginx后面通过HTTPS访问Django Admin
- nginx – 使用$http_host危险吗?
- ruby-on-rails-capistrano部署后ec2服务器中缺少puma.sock
- 我使用自制软件来安装nginx,以及如何添加第3个模块?
- 如何读取从nginx传递的python / flask中的UWSGI参数
- nginx通过ip限制目录访问
- node.js-Nginx反向代理:如何通过子域访问不同的容器?
- 如何在不重新加载/重启fpm本身的情况下将池添加到
- python – 使用压缩数据填充memcached,直接从ngi
- node.js – Meteor WebSocket握手错误400与nginx
- javascript – 502使用ExpressJS与nginx时网关不
- 在Kubernetes上使用Nginx SSL代理运行Meteor应用
- Nginx指向子目录到root
- ruby-on-rails-Nginx,Unicorn和Rails = 502错误网
- php – NGINX’Access-Control-Allow-Origin’标
- 使用Nginx在PHP-FPM 7上启用错误日志记录?
- nginx-我真的需要Web服务器以及API-微服务架构中