2016-08-04 44 views
0

讓我帶你到This page with HTTPSthis page without。這是一個Wordpress網站,不管怎樣,URL(和鏈接到)都需要HTTPS://在前面,否則最終會出現一個空白頁面。爲什麼前面沒有「https://」的URL會導致空白頁面?

讓我們概括一下情況並澄清發生了什麼,因爲我不知道是什麼原因造成的。希望你們可以告訴我如何解決這個問題,所以沒有https://的URL仍然顯示相同的頁面?

可能的.htaccess/nginx.conf和重定向到 '以https://' 會做>

服務器運行的是NGINX

我的nginx.conf文件:

# HTTP -> HTTPS 
    server { 
    listen 80; 
    server_name ttr.nl www.ttr.nl; 
    return 301 https://ttr.nl$request_uri; 
    } 

    http { 
     client_max_body_size 100m; 
    } 
    # BEGIN W3TC Page Cache cache 
    location ~ /wp-content/cache/page_enhanced.*html$ { 
     expires modified 7200s; 
     add_header X-Powered-By "W3 Total Cache/0.9.4.1"; 
     add_header Vary "Accept-Encoding, Cookie"; 
     add_header Pragma "public"; 
     add_header Cache-Control "max-age=7200, public"; 
    } 
    location ~ /wp-content/cache/page_enhanced.*gzip$ { 
     gzip off; 
     types {} 
     default_type text/html; 
     expires modified 7200s; 
     add_header X-Powered-By "W3 Total Cache/0.9.4.1"; 
     add_header Vary "Accept-Encoding, Cookie"; 
     add_header Pragma "public"; 
     add_header Cache-Control "max-age=7200, public"; 
     add_header Content-Encoding gzip; 
    } 
    # END W3TC Page Cache cache 
    # BEGIN W3TC Browser Cache 
    gzip on; 
    gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon; 
    location ~ \.(css|htc|less|js|js2|js3|js4)$ { 
     expires 2592000s; 
     add_header Pragma "public"; 
     add_header Cache-Control "max-age=2592000, public"; 
     add_header X-Powered-By "W3 Total Cache/0.9.4.1"; 
    } 
    location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ { 
     expires 7200s; 
     add_header Pragma "public"; 
     add_header Cache-Control "max-age=7200, public"; 
     add_header X-Powered-By "W3 Total Cache/0.9.4.1"; 
    } 
    location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip)$ { 
     expires 31536000s; 
     add_header Pragma "public"; 
     add_header Cache-Control "max-age=31536000, public"; 
     add_header X-Powered-By "W3 Total Cache/0.9.4.1"; 
    } 
    # END W3TC Browser Cache 
    # BEGIN W3TC Page Cache core 
    set $w3tc_rewrite 1; 
    if ($request_method = POST) { 
     set $w3tc_rewrite 0; 
    } 
    if ($query_string != "") { 
     set $w3tc_rewrite 0; 
    } 
    if ($request_uri !~ \/$) { 
     set $w3tc_rewrite 0; 
    } 
    if ($http_cookie ~* "(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle)") { 
     set $w3tc_rewrite 0; 
    } 
    if ($http_cookie ~* "(w3tc_preview)") { 
     set $w3tc_rewrite _preview; 
    } 
    set $w3tc_ssl ""; 
    if ($scheme = https) { 
     set $w3tc_ssl _ssl; 
    } 
    set $w3tc_enc ""; 
    if ($http_accept_encoding ~ gzip) { 
     set $w3tc_enc _gzip; 
    } 
    set $w3tc_ext ""; 
    if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_rewrite.html$w3tc_enc") { 
     set $w3tc_ext .html; 
    } 
    if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_rewrite.xml$w3tc_enc") { 
     set $w3tc_ext .xml; 
    } 
    if ($w3tc_ext = "") { 
     set $w3tc_rewrite 0; 
    } 
    if ($w3tc_rewrite = 1) { 
     rewrite .* "/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_rewrite$w3tc_ext$w3tc_enc" last; 
    } 
    # END W3TC Page Cache core 

    #gzip via varvy.com 
+0

聽起來確實像一個htaccess問題。前一段時間我和我的SMF論壇有同樣的問題,那就是問題所在。 –

+0

期望的結果是重定向非https https?或者使http和httpS工作?無論哪種方式,請發佈您的htaccess文件 –

+0

我希望我的網站僅使用SSL,無論您將「https://」放在URL前面,它都應該可以正常工作。 –

回答

2

對這些URL中的每一個的請求將轉到服務器上的其他端口。

很可能(但不是必需)同一部分軟件正在偵聽兩個端口上的請求。如果不同的軟件(例如Apache和Lighttpd)在不同的端口上偵聽,則每個軟件都需要配置爲單獨做你想做的事情。

如果它是同一塊軟件,那麼每個端口將會有不同的配置(必須有一個需要打開SSL,另一個不能)。

這些不同的配置可能有任何數量的差異,例如不同的DocumentRoot。 OTOH,他們可以輕鬆共享大量的配置數據。


您應該如何解決這個問題的一般情況是:配置HTTP URL以發出301重定向到匹配的HTTPS URL。

的具體情況如何您修復它將取決於如何設置服務器。

+0

我只是打電話給我們的服務器部門,因爲我只做前端。但是在我們的電話中,我們注意到 - 有些頁面在兩種情況下都可以工作(帶和不帶https://)。所以我想不是服務器相關的,但更多的網站相關。而且..我不確定現在在哪裏搜索。 - 儘管如此,按照SO的要求,這個問題是特定的而不是一般的。 –

+0

嗨昆汀,我做了一些進一步的調查,但顯然有些網頁只有這個問題,而不是所有的網頁。所以我認爲這不是服務器相關的,而是Wordpress或服務器本身的設置。但是與服務器配置沒有直接關係,比如端口。 你有任何其他想法可以解決這個問題嗎? –

相關問題