我正在尝试进行重定向以强制访问者进入https://www.my-site.com
我尝试感谢question,但出现错误。
HTTP标头
>>> http://my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Content-Type: text/html; charset=iso-8859-1
Content-Length: 240
Connection: close
Date: Sat, 18 May 2019 12:16:53 GMT
Server: Apache
Location: https://my-site.com/
Cache-Control: max-age=3600
Expires: Sat, 18 May 2019 13:16:53 GMT
>>> https://my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Content-Type: text/html; charset=iso-8859-1
Content-Length: 244
Connection: close
Date: Sat, 18 May 2019 12:16:53 GMT
Server: Apache
Location: https://www.my-site.com/
Cache-Control: max-age=3600
Expires: Sat, 18 May 2019 13:16:53 GMT
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:53 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=dde6584f7964addcf9b063498541c18721558181813; expires=Sun, 17-May-20 12:16:53 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 398f01b991 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:53 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3ce6bdc96ce-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:53 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d21f9af172659e90e3fe8c85235c69e6e1558181813; expires=Sun, 17-May-20 12:16:53 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 10b6d707db stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:53 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3ceeda8d6bd-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:53 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=da22780c09d88865e9d35fdc43f8d53e81558181813; expires=Sun, 17-May-20 12:16:53 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 48ec634287 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:53 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3cf7a5ed6d9-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:54 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d202c04c0b26a20b2e2dece1c597354741558181813; expires=Sun, 17-May-20 12:16:53 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: f7506a5073 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:54 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3d0d98d63c5-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:54 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d28df17bc69474bac406ffc8cf1cb9f9b1558181814; expires=Sun, 17-May-20 12:16:54 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 3d5c4b11e4 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:54 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3d2094c6437-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:54 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d04b5939675e6948b6b2416464c4f38a91558181814; expires=Sun, 17-May-20 12:16:54 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: bb5d78f708 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:54 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3d33e7097c6-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:54 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d19f5ff9f259d41e9e451e8351bccda641558181814; expires=Sun, 17-May-20 12:16:54 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 5680f0b02e stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:54 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3d479d59abc-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:54 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d41fd7549b5362dffcd7bdf0b1eb22daf1558181814; expires=Sun, 17-May-20 12:16:54 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 61f9380052 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:54 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3d5da05c2fe-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:55 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d1851c9ae8eaa5e9e03f57ecbb7c90c2e1558181814; expires=Sun, 17-May-20 12:16:54 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: f0d72f2e2a stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:55 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3d6f9f6c2db-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:55 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=dcd3b3e66a55246e0e45f3ab7d8585e1e1558181815; expires=Sun, 17-May-20 12:16:55 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: ec769a0282 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:55 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3d84d4664c1-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:55 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d6ba08f72ec40fb46df1063c3b01583a41558181815; expires=Sun, 17-May-20 12:16:55 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 9df7b1a19d stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:55 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3d98d88c2c2-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:55 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d6064ca8aba314379b0cec8fb851b494c1558181815; expires=Sun, 17-May-20 12:16:55 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 557ea2b9d4 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:55 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3dabb30d6d5-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:55 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d42946caede2e9c89d246624c867bd7781558181815; expires=Sun, 17-May-20 12:16:55 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: be701b5c17 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:55 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3db498bd6e1-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:55 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d33166088044061881d61d9cc796200b51558181815; expires=Sun, 17-May-20 12:16:55 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 71e37a46a7 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:55 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3dc1d4fc272-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:56 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=dc5be2e015943a08ef999c16266a0c7db1558181815; expires=Sun, 17-May-20 12:16:55 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 6b4613e71c stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:56 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3dd4cfcbedd-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:56 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=da45d2f76321cf1bf5ec8fb65430afdc31558181816; expires=Sun, 17-May-20 12:16:56 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 958c62ad09 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:56 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3deaf22bf00-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:56 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=d73d99431e0a6213e2a109fed4b3818c21558181816; expires=Sun, 17-May-20 12:16:56 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: c2d0351143 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:56 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3dfc978c2c7-FRA
>>> https://www.my-site.com/
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Sat, 18 May 2019 12:16:56 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: close
Set-Cookie: __cfduid=dead812916e289431d7991e8ef08a92841558181816; expires=Sun, 17-May-20 12:16:56 GMT; path=/; domain=.my-site.com; HttpOnly
Cache-Control: max-age=3600
Cf-Railgun: 98c0b46e67 stream 0.000000 0210 e6be
Expires: Sat, 18 May 2019 13:16:56 GMT
Location: https://www.my-site.com/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4d8dc3e0fc56d6cd-FRA
.htaccess
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/cache-manifest
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/vcard
AddOutputFilterByType DEFLATE text/vnd.rim.location.xloc
AddOutputFilterByType DEFLATE text/vtt
AddOutputFilterByType DEFLATE text/x-component
AddOutputFilterByType DEFLATE text/x-cross-domain-policy
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/ld+json
AddOutputFilterByType DEFLATE application/atom+xml
AddOutputFilterByType DEFLATE application/manifest+json
AddOutputFilterByType DEFLATE application/rdf+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/schema+json
AddOutputFilterByType DEFLATE application/vnd.geo+json
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-web-app-manifest+json
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE font/eot
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE image/bmp
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/vnd.microsoft.icon
AddOutputFilterByType DEFLATE image/x-icon
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css A2419200
ExpiresByType text/x-component A2419200
ExpiresByType application/x-javascript A2419200
ExpiresByType application/javascript A2419200
ExpiresByType text/javascript A2419200
ExpiresByType text/x-js A2419200
ExpiresByType text/html A3600
ExpiresByType text/richtext A3600
ExpiresByType image/svg+xml A3600
ExpiresByType text/plain A3600
ExpiresByType text/xsd A3600
ExpiresByType text/xsl A3600
ExpiresByType text/xml A3600
ExpiresByType video/asf A2419200
ExpiresByType video/avi A2419200
ExpiresByType image/bmp A2419200
ExpiresByType application/java A2419200
ExpiresByType video/divx A2419200
ExpiresByType application/msword A2419200
ExpiresByType application/vnd.ms-fontobject A2419200
ExpiresByType application/x-msdownload A2419200
ExpiresByType image/gif A2419200
ExpiresByType application/x-gzip A2419200
ExpiresByType image/x-icon A2419200
ExpiresByType image/jpeg A2419200
ExpiresByType application/json A2419200
ExpiresByType application/vnd.ms-access A2419200
ExpiresByType audio/midi A2419200
ExpiresByType video/quicktime A2419200
ExpiresByType audio/mpeg A2419200
ExpiresByType video/mp4 A2419200
ExpiresByType video/mpeg A2419200
ExpiresByType application/vnd.ms-project A2419200
ExpiresByType application/x-font-otf A2419200
ExpiresByType application/vnd.ms-opentype A2419200
ExpiresByType application/vnd.oasis.opendocument.database A2419200
ExpiresByType application/vnd.oasis.opendocument.chart A2419200
ExpiresByType application/vnd.oasis.opendocument.formula A2419200
ExpiresByType application/vnd.oasis.opendocument.graphics A2419200
ExpiresByType application/vnd.oasis.opendocument.presentation A2419200
ExpiresByType application/vnd.oasis.opendocument.spreadsheet A2419200
ExpiresByType application/vnd.oasis.opendocument.text A2419200
ExpiresByType audio/ogg A2419200
ExpiresByType application/pdf A2419200
ExpiresByType image/png A2419200
ExpiresByType application/vnd.ms-powerpoint A2419200
ExpiresByType audio/x-realaudio A2419200
ExpiresByType image/svg+xml A2419200
ExpiresByType application/x-shockwave-flash A2419200
ExpiresByType application/x-tar A2419200
ExpiresByType image/tiff A2419200
ExpiresByType application/x-font-ttf A2419200
ExpiresByType application/vnd.ms-opentype A2419200
ExpiresByType audio/wav A2419200
ExpiresByType audio/wma A2419200
ExpiresByType application/vnd.ms-write A2419200
ExpiresByType application/font-woff A2419200
ExpiresByType application/vnd.ms-excel A2419200
ExpiresByType application/zip A2419200
</IfModule>
#<IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteBase /
# RewriteRule ^index\.php$ - [L]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule . /index.php [L]
#</IfModule>
AddHandler x-mapp-php5.5 .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#Redirection vers HTTPS - JOHAN MAIA
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
# END WordPress
# Wordfence WAF
<Files ".user.ini">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Files>
# END Wordfence WAF
我的错误是什么?
答案 0 :(得分:0)
不确定您的为什么不工作。看起来不错。但是,您可以尝试匹配确切的HTTP_HOST,而不是更通用的“ www不存在”匹配:
RewriteCond %{HTTP_HOST} ^my-site\.com$
RewriteRule ^(.*)$ "https\:\/\/www\.my-site\.com\/$1" [R=301,L]