php - nginx配置文件请教?
本文介绍了php - nginx配置文件请教?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
server {
listen 80;
server_name man.cn;
root /usr/local/www/test_demo/htdocs/public;
index index.php index.html index.htm;
charset utf-8;
if ( $request_uri ~* ^(/web)){
rewrite ^/web/(.*)$ /dist/index.html;
}
if ( $request_uri ~* ^(/api)){
rewrite ^/api/(.*)$ /index.php?=url=$1 last;
}
location ^~ / {
rewrite /dist/(.+)$ /$1 break;
proxy_pass http://man.com/web/dashboard/;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9071;
fastcgi_index /index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
请教一下,现在想实现这样的效果:
我们现在的效果是;
http://man.cn/web/dashboard带web走静态解析
http://man.cn/api/test/ak带api走php解析
现在想实现的是http://man.cn走静态解析,请问怎么做?
解决方案
location /api {
fastcgi_pass 127.0.0.1:9071;
fastcgi_index /index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location / {
root /usr/local/www/test_demo/htdocs/public;
}
这篇关于php - nginx配置文件请教?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文