我在我的文件中使用了这段代码.htaccess
:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^silkgifts.co.uk
RewriteRule (.*) https://www.silkgifts.co.uk/$1 [R=301,L]
它将我的 HTTPS 非 www 定向到 HTTPS www 站点,也将 HTTP 非 www 定向到 HTTPS www 站点。但是,它没有将 HTTP www 定向到 https www。
我还输入了此代码来尝试解决问题:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
它在 Google Search Console 中运行正常,但在其他网站上测试时,它说存在无限的重定向链,所以我将其删除了。
谁能告诉我我哪里错了?
编辑:当前.htaccess
文件:
AddHandler php56-script .php .php5
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
RewriteEngine On
RewriteCond %{HTTP_HOST} ^silkgifts.co.uk
RewriteRule (.*) https://www.silkgifts.co.uk/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]