Nginx下使Thinkphp URL模式支持PATHINFO和REWRITE
2017-06-08 00:38
597 查看
轉:http://blog.csdn.net/codercwm/article/details/52786712
1.支持PATHINFO
2
3
4
1
2
3
4
即
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
2.支持REWRITE去掉index.PHP
2
3
4
5
6
1
2
3
4
5
6
即
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
如果thinkphp不是部署在网站根目录下,即需要把
2
3
1
2
3
如果根目录下有多个项目的话,可以写多个rewrite:
1.支持PATHINFO
找到location ~ \.php { ,把$去掉,并在里面加上这两句 fastcgi_split_path_info ^(.+\.php)(.*)$; #增加 fastcgi_param PATH_INFO $fastcgi_path_info; #增加1
2
3
4
1
2
3
4
即
location ~ \.php { #去掉$ root html fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(.*)$; #添加 fastcgi_param PATH_INFO $fastcgi_path_info; #添加 }1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
2.支持REWRITE去掉index.PHP
找到location / { 在里面加上 if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?s=$1 last; break; }1
2
3
4
5
6
1
2
3
4
5
6
即
location / { root html index index.html index.htm index.php; if (!-e $request_filename) { #添加 rewrite ^/(.*)$ /index.php?s=$1 last; #添加 4000 break; #添加 } #添加 }1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
如果thinkphp不是部署在网站根目录下,即需要把
rewrite ^/(.*)$ /index.php?s=$1 last; 改成 rewrite ^/子目录/(.*)$ /子目录/index.php?s=$1 last;1
2
3
1
2
3
如果根目录下有多个项目的话,可以写多个rewrite:
if (!-e $request_filename) { rewrite ^/项目1/(.*)$ /项目1/index.php?s=$1 last; rewrite ^/项目2/(.*)$ /项目2/index.php?s=$1 last; rewrite ^/项目3/(.*)$ /项目3/index.php?s=$1 last; break; }
相关文章推荐
- Nginx下使Thinkphp URL模式支持PATHINFO和REWRITE
- 在nginx中配置pathinfo模式支持thinkphp的URL重写
- 详解ThinkPHP支持的URL模式有四种普通模式、PATHINFO、REWRITE和兼容模式
- 让nginx支持thinkphp的rewrite模式(url_model为2)
- nginx 支持thinkphp pathinfo模式
- Nginx下实现pathinfo及ThinkPHP的URL Rewrite模式支持
- 配置nginx1.8支持thinkPHP3.2 pathinfo模式
- 【Nginx重写】下支持ThinkPHP的Pathinfo和URl Rewrite模式
- ThinkPHP 3.2 在 Nginx 下配置 URL 模式为 REWRITE 模式
- nginx环境支持thinkphp的pathinfo模式
- LNMP 配置NGINX 支持THINKPHP PATHINFO模式
- Nginx下支持ThinkPHP的Pathinfo和URl Rewrite模式
- Nginx下实现pathinfo及ThinkPHP的URL Rewrite模式支持
- 让nginx支持thinkmcf或thinkphp rewrite模式
- Nginx下实现pathinfo及ThinkPHP的URL Rewrite模式支持
- Nginx支持thinkphp pathinfo模式
- Nginx下实现pathinfo及ThinkPHP的URL Rewrite模式支持
- nginx配置使其支持thinkphp的pathinfo模式
- Nginx上ThinkPHP的PATHINFO模式支持
- Nginx下实现pathinfo及ThinkPHP的URL Rewrite模式支持