nginx重写浏览器地址出现url拼接异常

nginx重写浏览器地址出现url拼接异常

我想要用nginx实现如下功能:

https://www.example.com/project1--> /数据/www/pro1/公共

https://www.example.com/project2--> /数据/www/pro2/公共

这是我的nginx配置:

server {
    listen 80;
    server_name www.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen  443 ssl;
    server_name www.example.com;
    index index.html index.php;
    root html;

    rewrite_log on;

    error_log /data/wwwlogs/itjuzi/xxxerror.log debug;

    access_log  /data/wwwlogs/itjuzi/saas.itjuzi.com.log  access;

    location /project1 {
        alias /data/www/pro1/public;
        try_files $uri $uri/ @pro1;

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include fastcgi_params;
            fastcgi_param HTTPS on;
            fastcgi_param HTTP_SCHEME https;
            fastcgi_param  PATH_INFO       $fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME $request_filename;
            }
    }

    location @pro1 {
        rewrite /project1/(.*)$ /project1/index.php?/$1 last;
    }

这可以正确访问pro1项目的index.php。

但是浏览器地址很奇怪:

https://www.example.com/https:/www.example.com/project1/login

这个问题困扰了我一整天。

帮帮我!!!谢谢 ^_^

相关内容