VPS侦探论坛

 找回密码
 注册
查看: 2782|回复: 3

单域名,虚拟目录,location配置后,php 解析404

[复制链接]
发表于 2019-12-3 16:50:54 | 显示全部楼层 |阅读模式

lnmp离线安装,通过一个域名www.xxx.com,访问www.xxx.com/abc,指向项目一。访问www.xxx.com/edf,指向项目二。创建vhost ,配置在附件里,配置location,解析php返回404。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2019-12-3 20:23:02 | 显示全部楼层


不清楚你目录结构,没法说
而且你写2个都是匹配目录的location也是有问题的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2019-12-4 10:37:02 | 显示全部楼层

licess 发表于 2019-12-3 20:23
不清楚你目录结构,没法说
而且你写2个都是匹配目录的location也是有问题的 ...

这个是nginx.conf的配置,我只是将原先的root与index注释,想用location去指定目录,访问php就404了
server
    {
        listen 80 default_server reuseport;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
       #index index.html index.htm index.php;
       #root  /opt/wwwroot/default;


       location  / {
                root /opt/wwwroot;
                index index.html index.htm index.php;
                include enable-php.conf;
        }

        #location /wxyjst {
        #       alias /opt/wwwroot/default/;
        #       index index.html index.php;
        #}

         #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }
include vhost/*.conf;
}
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2019-12-4 20:35:37 | 显示全部楼层



ziven 发表于 2019-12-4 10:37
这个是nginx.conf的配置,我只是将原先的root与index注释,想用location去指定目录,访问php就404了
serve ...

不清楚你网站目录结构没法说
root和alias是有明显区别的
root就是指定到目录到后面设定的目录上
alias是将location 后面匹配的路径等于所设置的目录上。
如果要location /wxyjst 这样只是匹配 域名/wxyjst 其他不匹配,目录下面的文件可以访问需要 location ^~ /wxyjst/
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-22 03:55 , Processed in 0.027258 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表