如何在 Opencart 期刊主题中将所有非 www 重定向到 www 和 SSL Url?

How to redirect all non-www to www and SSL Url in Opencart journal theme?

问题就像

  1. 当我使用 http://www.example.com 时:它工作正常。
  2. 当我使用 https://www.example.com 时:我的 www ssl 证书可以正常工作
  3. 当我使用 http://example.com 时:我丢失了样式和图标。
  4. 当我使用 https://example.com 时:我丢失了样式和图标。

现在我想要这些方式:

  1. 当我使用 http://example.com 时:它应该重定向到 https://www.example.com
  2. 当我使用 http://www.example.com 时:它应该重定向到 https://www.example.com
  3. 当我只使用 example.com 时:它应该重定向到 https://www.example.com

这是我现在的 .htaccess.txt

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^system/download/(.*) 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_= [L,QSA]

请指导我如何实现我想要的以及如何解决样式和图标问题。提前致谢!

检查下面的代码 htaccess:

RewriteCond %{HTTPS} off
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]