源支付最新伪静态 2025年6月2日更新-官方公告论坛-源支付V8-源支付V8

源支付最新伪静态 2025年6月2日更新

下面是最新版的伪静态,请替换为此最新的伪静态,文档教程已同步更新

# 禁止访问 runtime 和 application 目录
location ~* (runtime|application)/ {
    return 403;
}

# 支付和通知相关的重写规则
location ~ ^/api/notify/ {
    rewrite ^(.*)$ /index.php?s=$1 last;
    break;
}

location ~ ^/api/OAuthLogin/notify {
    rewrite ^(.*)$ /index.php?s=$1 last;
    break;
}

location ~ ^/pay/payment {
    rewrite ^(.*)$ /index.php?s=$1 last;
    break;
}

location ~ ^/alipaycashier {
    rewrite ^(.*)$ /index.php?s=$1 last;
    break;
}

location ~ ^/pay/cashier {
    rewrite ^(.*)$ /index.php?s=$1 last;
    break;
}

# 根路径配置
location / {
    # 处理首页访问
    if ($request_uri = "/") {
        rewrite ^/$ /index.php?s=/api/index/home&server=1 last;
    }

    # 处理跨域 OPTIONS 预检请求
    if ($request_method ~* OPTIONS) {
        add_header Access-Control-Max-Age '86400';
        add_header Access-Control-Allow-Origin '*';
        add_header Access-Control-Allow-Headers '*';
        add_header Access-Control-Allow-Credentials 'true';
        add_header Access-Control-Allow-Methods 'GET, POST, PATCH, PUT, DELETE, OPTIONS';
        return 204;
    }

    # 首页优先访问 index.html,实现隐藏 index.html 的效果
    index index.html index.php error/index.html;

    # URL 重写规则
    set $server 0;
    
    # 判断 server 参数
    if ($request_uri ~* "server=1") {
        set $server 1;
    }
    if ($http_server) {
        set $server 1;
    }

    # 重写规则执行
    if ($server = 1) {
        rewrite ^(.*)$ /index.php?s=/$1 last;
        break;
    }

    # 其他请求尝试访问静态资源,如果不存在则访问 index.html
    try_files $uri $uri/ /index.html;
}

 

请登录后发表评论

    没有回复内容