繁体   English   中英

没有www重定向到www的重定向不适用于URL

[英]Redirect without www to www does not work for a URL

我只有一个网址的重定向存在问题。 而且我不知道为什么它是唯一不遵循重定向命令的URL。

我希望所有网址都以www打开。

平台:

  • WordPress 4.8.1
  • 服务器:Nginx-Ubuntu 14.04.5 LTS
  • 使用Easy Engine完成安装

注意:我已经完成了所有这些步骤: https : //easyengine.io/tutorials/nginx/www-non-www-redirection/

谢谢你的帮助!

https://www.example.org/ Redirecting to www (yes)
http://www.example.org/ Redirecting to www (yes)
https://example.org/ Redirecting to www (no) This is the problem url
http://example.org/ Redirecting to www (yes)

块名称服务器

server {
    server_name www.example.org example.org;

    access_log /var/log/nginx/example.org.access.log rt_cache;
    error_log /var/log/nginx/example.org.error.log;

    root /var/www/example.org/htdocs;

    index index.php index.html index.htm;

    include common/php.conf;
    include common/wpcommon.conf;
    include common/locations.conf;
    include /var/www/example.org/conf/nginx/*.conf;

}

强制SSL

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

测试

    ~# nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

测试重定向网址

~# curl -I https://example.org
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 23 Aug 2017 19:45:46 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Set-Cookie: PHPSESSID=qg3bp00ofo92bsgob5flr4co26; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Link: <https://www.example.org/wp-json/>; rel="https://api.w.org/"
Link: <https://www.example.org/>; rel=shortlink
X-Powered-By: EasyEngine 3.7.4

2º测试重定向网址

~# curl -I http://example.org
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 23 Aug 2017 20:05:56 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: https://www.example.org/
X-Powered-By: EasyEngine 3.7.4

从您的BLOCK NAME SERVER块中删除chefclub.com.br ,并添加一个新的服务器块

server {
    listen 443 ssl;
    server_name chefclub.com.br;
    include yoursslcertificate.conf;
    return 301 https://www.chefclub.com.br$request_uri;
}

就像您侦听端口80将所有流量重定向到www ,您还希望侦听non-www端口443 ,然后将其发送到www

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM