VPS侦探论坛

 找回密码
 注册
查看: 3033|回复: 4

二级目录问题

[复制链接]
发表于 2022-1-18 17:00:07 | 显示全部楼层 |阅读模式

本帖最后由 yangsen1030 于 2022-1-18 17:01 编辑

小白求助。之前公司只有一个项目,一个域名 www.chizou.com ,指定到项目目录 /home/www/szexp 。现在公司又多了一个项目。  我在服务上建立了另外一个项目,目录为 /home/www/szexp2 。 域名还是 www.chizou.com。想通过访问 www.chizou.com/szexp2/  访问到我新建的项目。论坛的大师能告诉我该怎么去做么,同时能保证访问 www.chizou.com 能指定到项目/home/www/szexp 不变。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2022-1-18 22:09:10 | 显示全部楼层

回帖奖励 +2 金钱



很简单!
在/home/www/szexp/目录下创建一个szexp2的目录,就可以通过www.chizou.com/szexp2/访问了,其他啥都不用修改!
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2022-1-19 11:10:24 | 显示全部楼层

  1.         location /testabc/ {
  2.             index index.html index.php;
  3.             root /home/www;
  4.         include enable-php.conf;
  5. }
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2022-1-19 17:31:58 | 显示全部楼层




server
    {
        listen 9080;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root  /home/wwwroot/Beckman;

        #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  /szexp {
                root  /home/wwwroot/szexp;
                index  index.html index.htm;
        }

        location / {
            index   index.html index.htm index.php;
            #try_files $uri $uri/ /index.php;
                          if (!-e $request_filename) {
              rewrite ^(.*)$ /index.php?s=$1 last;
              break;            }
        }
        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;
    }
麻烦大佬帮忙看一下,我这里配的是哪里有问题。文件是 nginx.conf
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2022-1-20 13:17:56 | 显示全部楼层

yangsen1030 发表于 2022-1-19 17:31
server
    {
        listen 9080;

testabc 替换为你自己的目录,testabc对应 loaction里面root为testabc目录的上级目录
你要用你对应的域名,你去改nginx.conf 肯定也不行,要改对应域名.conf

2楼的方法最简单,啥都不用考虑

军哥运维代购:http://shop63846532.taobao.com/

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-20 17:26 , Processed in 0.026787 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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