ThinkPHP3.2.3+Nginx的伪静态配置
2016-05-17 10:06
513 查看
用TP框架开发的公司项目,URL模式是REWRITE模式('URL_MODEL' => 2,),上传至服务器,发现URL重写这块出现了问题,于是研究了一下,找到了答案,写下备忘:
如以上代码注释【#ThinkPHP REWRITE支持】。
如果ThinkPHP项目安装在二级目录,Nginx的伪静态方法设置如下,其中subdir是所在的目录名称
server { listen 80; server_name www.vc.cn; index index.php; root /data/wwwroot/vc; #error_page 404 /404.html; location / { index index.php; #ThinkPHP REWRITE支持 if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?s=$1 last; } #301 跳转设置 if ($host = 'vc.cn') { rewrite ^/(.*) http://www.vc.cn/$1 permanent; } } location ~ [^/]\.php(/|$) { # comment try_files $uri =404; to enable pathinfo try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; #include pathinfo.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } access_log /home/wwwlogs/vc.log access; }
如以上代码注释【#ThinkPHP REWRITE支持】。
如果ThinkPHP项目安装在二级目录,Nginx的伪静态方法设置如下,其中subdir是所在的目录名称
location /subdir/ { if (!-e $request_filename){ rewrite ^/subdir/(.*)$ /subdir/index.php?s=$1 last; } }
相关文章推荐
- nginx常用命令
- windows环境下使用nginx
- 通过设置nginx的client_max_body_size解决nginx+php上传大文件的问题
- Nginx+php-fpm 502 504问题
- 配置Nginx支持pathinfo模式
- 教你编译PHP7 (nginx+mysql+php7)
- 使用Nginx反向代理 让IIS和Tomcat等多个站点一起飞
- Nginx配置
- Nginx配置性能深度优化
- Nginx 的启动、停止、平滑重启、信号控制和平滑升级
- nginx + php
- nginx+ ffmpeg 实现 hls直播和点播
- centos6.6搭建LNMP(Php5.6.2+Mysql5.6.21+Nginx1.6.2)
- keepalived基于nginx实现双主模型
- nginx: [warn] conflicting server name "locahost" on 0.0.0.0:80, ignored
- 使用xhprof会在nginx下报502 Bad Gateway错误
- Nginx+uWSGI+Django原理
- nginx 搭建rtmp流媒体服务器流程笔记
- nginx的配置及模块详解
- nginx location