如何解决如何在Nginx上添加自定义PHP位置
我已经配置了一个Yii2高级模板站点(高级意味着2个站点:第一个是前端站点,第二个是管理区域)
我的前端(Nginx的根)位于/ public_html,而我的管理员位于/ public_html / admin。
除了以“不同方式”开发的两个端点外,几乎所有东西都可以工作。
我认为这是我的问题所在:通常,任何请求都将指向www.mysite.com/
很遗憾,我有两个www.mysite.com/
这是我的意思:
常规前端路线
- 请求网址:www.mysite.com /索引
- 所有到达public_html / index.php但由Nginx
location /
服务的路线
常规管理路线
- 请求网址:www.mysite.com/admin/索引
- 所有路由到public_html / admin / index.php,但由Nginx
location /admin
提供服务
非常规前端路由:
- 请求网址:www.mysite.com / not_index Nlix
- 路由到public_html / index.php 仍在投放
location /
非常规后端路由:
- 请求网址:www.mysite.com/admin/ not_index Nlix
- 路由到public_html / admin // index.php 仍在投放 我认为这是我的问题
location /admin
“很明显”,我的两个非常规路线都解析为404找不到。我无法为此找到解决方案。我已经待了好几天了...
这是我的nginx.conf:
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
root /var/www/mysite/public_html;
index index.php index.html index.htm;
server_name localhost;
location /admin {
root /var/www/mysite/public_html/admin;
index index.php;
try_files $uri /admin/index.php$is_args$args ;
location = /admin/ {
return 301 /admin;
}
location = /admin/frontend-users/search-influencers {
try_files /admin/$uri /admin/$uri.php;
}
}
location / {
root /var/www/mysite/public_html;
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(css|map|mp3|mp4|js|jpg|jpeg|png|gif|bmp|ico|mov|swf|pdf|zip|rar)$ {
access_log off;
log_not_found on;
try_files $uri /public_html/$uri =404;
}
}
我在做什么错了?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。