php - nginx的location怎么设置匹配前后台地址?
本文介绍了php - nginx的location怎么设置匹配前后台地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
我的配置:
server {
listen 80;
server_name www.xxx.com xxx.com;
# server_name_in_redirect off;
root /alidata/www/default/yooao/frontend/web;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
index index.php ;
root /alidata/www/default/yooao/frontend/web;
}
location ~ ^/backend$ {
index index.php ;
root /alidata/www/default/yooao/backend/web;
}
}
现在是前台可以进去,后台却不对,我用的是yii2框架。之前没加
`location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}`
时进前台首页会变成下载页面。现在我想匹配url进后台不知道该怎么做了,现在进后台www.xxx.com/backend显示404,新手求指教
解决方案
官网文档明确给出如何配置 nginx,地址是:http://www.getyii.com/doc-2.0/guide/start-installation.html#nginx
如果你使用的是高级版,项目初始化完成之后,frontend,backend 需要分别配置,即要配置两个vhost
这篇关于php - nginx的location怎么设置匹配前后台地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文