当前位置:论坛首页 > Linux面板 > 求助

想让一个单独前缀的请求访问 某个location 并且设置root路径

发表在 Linux面板2025-10-9 20:44 [复制链接] 1 110

本帖最后由 宝塔用户_canchp 于 2025-10-9 20:48 编辑

为了能快速了解并处理您的问题,请提供以下基础信息:
各位大佬   我想让 tenantapi 的请求  单独走一个 location里  并且根目录 单独在location里设置 , 项目 目录 app 下面分了多个目录 tenantapi 和其他的 有什么解决方案吗 nginx 不太熟悉,求指教。

listen 80;
    server_name 2b7168.test6.com test6.com;
    index index.php index.html index.htm default.php default.htm default.html;
    # root D:/wwwroot/sass-oa/judianshang/server/public;
    # 处理 tenantapi 前缀的所有请求
    location ^~/tenantapi/ {

        # Tenant API 路由处理
       alias D:/wwwroot/sass-oa/judianshang/server/public;
        if (!-e $request_filename) {
            rewrite ^/tenantapi/(.*)$ /index.php?s=/tenantapi/$1 last;
            break
        }

    }
    location ~ \.php(.*)$ {
       try_files $uri =404;
       fastcgi_pass 127.0.0.1:20080;
       fastcgi_index index.php;

       set $real_script_name $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
            set $real_script_name $1;
            set $path_info $2;
        }
       fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
       fastcgi_param SCRIPT_NAME $real_script_name;
       fastcgi_param PATH_INFO $path_info;

       include fastcgi_params;
    }


使用道具 举报 只看该作者 回复
发表于 2025-10-9 20:51:43 | 显示全部楼层
截图上来字符就超了  复制文字上来竟然有 北京颜色
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术免费分析

工作时间:09:00至18:30

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