0
我有我的Apache2 web服務器上的配置:Apache2的配置不是重定向端口80上的所有請求443
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2016-07-14T12:32:26
我想重定向所有的HTTP流量到HTTPS:
<VirtualHost *:80>
RewriteEngine On
RewriteRule^https://www.example.com%{REQUEST_URI} [R=301,L]
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule^https://www.example.com%{REQUEST_URI} [R=301,L]
...
</VirtualHost>
然而
我的配置是工作的罰款,我跑進了以下問題:
> curl -IL "http://example.com/"
HTTP/1.1 301 Moved Permanently
Date: Tue, 25 Apr 2017 14:44:25 GMT
Server: Apache/2.4.18 (Ubuntu)
Location: https://www.example.com/
Content-Type: text/html; charset=iso-8859-1
HTTP/1.1 200 OK
Date: Tue, 25 Apr 2017 14:44:25 GMT
Keep-Alive: timeout=10
Connection: Keep-Alive
Accept-Ranges: bytes
Cache-Control: must-revalidate, max-age=604800
Content-Length: 226
Content-Type: text/html
X-HW: 1493131465.dop004.la2.t,1493131465.cds052.la2.shn,1493131465.dop004.la2.t,1493131465.cds025.la2.c
Last-Modified: Thu, 16 Feb 2017 17:05:44 GMT
Access-Control-Allow-Origin: *
Vary: Accept-Encoding
GEO: US
ETag: "e2-548a8cec41423"
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
> curl -IL "http://www.example.com/"
HTTP/1.1 200 OK
Date: Tue, 25 Apr 2017 14:42:57 GMT
Keep-Alive: timeout=10
Connection: Keep-Alive
Accept-Ranges: bytes
Cache-Control: must-revalidate, max-age=604800
Content-Length: 226
Content-Type: text/html
X-HW: 1493131377.dop006.la2.t,1493131377.cds025.la2.c
Last-Modified: Thu, 16 Feb 2017 17:05:44 GMT
Access-Control-Allow-Origin: *
Vary: Accept-Encoding
GEO: US
ETag: "e2-548a8cec41423"
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
正如你可以在上面捲曲我的網頁SER看ver正在將非www的HTTP流量重定向到www HTTPS,但是,當我嘗試從www HTTP到www HTTPS的同一個重定向時,它會失敗,並顯示一個200,我應該得到一個301.
此時的任何建議將不勝感激。