Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.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
Redirect 将www和非www重定向到https非www_Redirect_Nginx - Fatal编程技术网

Redirect 将www和非www重定向到https非www

Redirect 将www和非www重定向到https非www,redirect,nginx,Redirect,Nginx,所以我正在尝试,将http www和非www重定向到https非www 但我只是注意到重定向只在chrome上起作用,而在另一方面,它们在尝试了一段时间后就消失了,无法打开页面。我认为在chrome中工作是因为过去的缓存,所以它实际上不工作。。。有什么想法吗 这是一个curl-i结果,似乎有一个重定向 HTTP/1.1 301 Moved Permanently Server: nginx/1.9.12 Date: Tue, 22 Mar 2016 22:10:34 GMT Content-T

所以我正在尝试,将http www和非www重定向到https非www

但我只是注意到重定向只在chrome上起作用,而在另一方面,它们在尝试了一段时间后就消失了,无法打开页面。我认为在chrome中工作是因为过去的缓存,所以它实际上不工作。。。有什么想法吗


这是一个curl-i结果,似乎有一个重定向

HTTP/1.1 301 Moved Permanently
Server: nginx/1.9.12
Date: Tue, 22 Mar 2016 22:10:34 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location: http://domain.com/

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.9.12</center>
</body>
</html>
HTTP/1.1 301永久移动
服务器:nginx/1.9.12
日期:2016年3月22日星期二格林尼治标准时间22:10:34
内容类型:text/html
内容长度:185
连接:保持活力
地点:http://domain.com/
301永久搬迁
301永久搬迁

nginx/1.9.12
创建
服务器
块以处理重定向

server {
    listen       80;
    server_name  www.domain.com domain.com;
    return 301   https://www.domain.com$request_uri;
}
server {
    listen 443   ssl http2;
    server_name  www.domain.com;

    # Add ssl_<*> directives here, if necessary.

    return 301   https://domain.com$request_uri;
}
server {
    listen       443 ssl http2;
    server_name  domain.com;

    # Add ssl_<*> directives here, if necessary.
    # And other configurations...
}
服务器{
听80;
服务器名称www.domain.com domain.com;
返回301https://www.domain.com$request_uri;
}
服务器{
监听443sslhttp2;
服务器名称www.domain.com;
#如有必要,在此处添加ssl_uu指令。
返回301https://domain.com$request_uri;
}
服务器{
监听443sslhttp2;
server_name domain.com;
#如有必要,在此处添加ssl_uu指令。
#和其他配置。。。
}
server {
    listen       80;
    server_name  www.domain.com domain.com;
    return 301   https://www.domain.com$request_uri;
}
server {
    listen 443   ssl http2;
    server_name  www.domain.com;

    # Add ssl_<*> directives here, if necessary.

    return 301   https://domain.com$request_uri;
}
server {
    listen       443 ssl http2;
    server_name  domain.com;

    # Add ssl_<*> directives here, if necessary.
    # And other configurations...
}