Nginx 开启PATHINFO支持ThinkPHP框架实例
2016-07-19 07:24
501 查看
ThinkPHP支持通过PATHINFO和URL rewrite的方式来提供友好的URL,只需要在配置文件中设置 'URL_MODEL' => 2 即可。在Apache下只需要开启mod_rewrite模块就可以正常访问了,但是Nginx中默认是不支持PATHINFO的,所以nginx默认情况下是不支持ThinkPHP的。不过我们可以通过修改nginx的配置文件来让其支持ThinkPHP。
虚拟主机配置文件: nginx/conf/vhost/127.0.0.1_8090.conf
虚拟主机配置文件: nginx/conf/vhost/127.0.0.1_8090.conf
server { listen 8040; server_name 127.0.0.1:8040; access_log logs/127.0.0.1_8040.access.log main; location / { root /www/jingchang/jc_live; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } location ~ \.php { root /www/jingchang/jc_live; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; } }
相关文章推荐
- 0142 nginx搭建rtmp协议流媒体服务器总结
- Nginx 工作原理和优化、漏洞
- nginx(一)安装与命令总结
- Linux系统下 安装nginx时出现提示的错误:configure: error: You need a C++ compiler for C++ support.
- nginx的安装配置
- nginx: [emerg] unknown directive
- Linux系统下 安装nginx时出现提示的错误:configure: error: You need a C++ compiler for C++ support.
- nginx 正则表达式匹配
- nginx配置非80端口访问不了
- Mac下安装 php+nginx+mysql 开发环境
- nginx location匹配顺序
- Nginx配置性能优化
- nginx生产环境常用功能include 、虚拟主机别名、rewrite、nginx status详细解析、fastcgi、访问控制
- nginx上传文件
- nginx对比apache
- Nginx/LVS/HAProxy负载均衡软件的优缺点
- nginx配置
- Ubuntu nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
- centos 部署nginx + python3 +uwsgi
- Windows下配置nginx+php(wnmp)