我已经在我的网站上完成了安全保护(https),如果我打开我的网站意味着它显示为(http://www.kuberansilks.in/),但是当我在浏览器中打开时,它会自动采用https安全协议, 并且网址看起来像(https://www.kuberansilks.in)。那么,我该如何避免这个问题,请帮助我(我使用的是AWS服务器)。
我的htaccess代码请检查:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^kuberansilks\.in [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.kuberansilks.in/$1 [R,L]
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
答案 0 :(得分:0)
使用以下代码
更新您的ht-access文件RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^kuberansilks\.in [NC]
//Added lines
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.kuberansilks.in/$1 [R,L]
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
更新后的代码:
RewriteEngine On
RewriteCond %{HTTPS} !=off
RewriteRule ^/?(checkout|account|admin) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^site\.co\.uk [NC]
RewriteRule ^(.*)$ https://www.site.co.uk/$1 [R,L]
config.php
// HTTP
define('HTTP_SERVER', 'https://www.site.co.uk/');
// HTTPS
define('HTTPS_SERVER', 'https://www.site.co.uk/');
define('HTTPS_IMAGE', 'https://www.site.co.uk/image/');
/admin/config.php
// HTTP
define('HTTP_SERVER', 'https://www.site.co.uk/admin/');
define('HTTP_CATALOG', 'https://www.site.co.uk/');
// HTTPS
define('HTTPS_SERVER', 'https://www.site.co.uk/admin/');
define('HTTPS_CATALOG', 'https://www.site.co.uk/');
define('HTTPS_IMAGE', 'https://www.site.co.uk/image/');
请检查它应该有效。