[nginx] 2025-02-13 圈点144
摘要:nginx配置thinkphp3.2的配置思路和规则
nginx配置thinkphp3.2的配置思路和规则
网络上找了很多关于nginx与thinkphp3.2的rewrite编写规则;感觉都没有太符合要求的,那就自己动手分析思路并写规则。
分析思路:
url_mode =2 (rewrite模式)
1,静态资源,有图片,js,css,等
2,静态化后所有网页的扩展名为.html
3,独立的php页面以.php结尾
基于这样的分析,规则如下:
location ~* ^.+.(jpg|jpeg|png|gif|css|js|ico)$ {
access_log off;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ \.html$ {
rewrite ^/(.*)$ /index.php?s=/$1;
}
location ~ \.php/ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+?\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi.conf;
}
思路分析:
1,静态资源直接引出;
2,.php结尾的页面也是直接引出;
3,html结尾的页面,先加上index.php/s= 这些字符,然后再继续解析出规则;
备注:除了页面有html结尾,其它如果要静态网页,可以用.htm 这样就可以区分;
下一篇[nginx]