Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
nginx重复位置“/&引用;错误_Nginx - Fatal编程技术网

nginx重复位置“/&引用;错误

nginx重复位置“/&引用;错误,nginx,Nginx,当scheme为http且位置为时,我想重定向到https/ server { listen 80; server_name bla; location / { return 301 https://bla; } include fs.inc; } 现在,问题是:fs.inc包含了另一个“location/”,即使从未调用过,nginx配置测试也会失败,在fs.inc:1中出现错误replicate loca

当scheme为http且位置为时,我想重定向到https/

server {
    listen          80;
    server_name     bla;

    location / {
        return 301 https://bla;
    }

    include fs.inc;
}
现在,问题是:fs.inc包含了另一个“location/”,即使从未调用过,nginx配置测试也会失败,在fs.inc:1中出现错误
replicate location/”


如何解决此问题?

您需要另一个服务器块:

server {
    listen 443;
    server_name bla; # make sure this is the same

    # add your ssl specific directives here

    location / {
        alias /var/www/secured/;
    }
}

server {
    listen 80;
    server_name bla;

    return 301 https://$request_uri;
}

这是一个全局重定向

hm,但我只想在location为only/时重定向到https,而不是更多。你是说如果链接是/hello,你想要它http吗?但是如果它/你想重定向到https?如果有人将/hello?
location=/
标记为书签,则表示完全匹配,而不是前缀