2017-08-23 51 views
0

我只有一個url的重定向有問題。 而我不知道爲什麼它是唯一不服從重定向命令的URL。沒有www到www的重定向對於URL不起作用

我希望所有的URL都可以用www打開。

平臺:

  • 的WordPress 4.8.1
  • 服務器:Nginx的 - 的Ubuntu 14.04.5 LTS
  • 安裝有方便的發動機做

注:我有已經完成了所有這些步驟: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; 

} 

FORCE SSL

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

TEST

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

TEST重定向URL

~# 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ºTEST重定向URL

~# 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 
+0

是什麼'https://www.chefclub.com.br/重定向ok'是什麼意思?什麼是重定向到? –

+0

所有與好的網址是他們正在做重定向,並與www打開。 – Fernando

回答

1

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

+0

不幸的是,這並不適合我。我的重定向僅在服務器上使用兩個塊時有效。這樣所有重定向工作。 但他們告訴我這是錯誤的。 – Fernando

+0

您是否從其他區塊刪除了「chefclub.com.br」?這假設毫無疑問地工作。 –

+0

是的,據我瞭解,我做到了。 但錯誤。 我的重定向只能以這種方式工作。 請看一下。 https://www.screencast.com/t/VaqSWTbqggF 謝謝! – Fernando