使用网址时,我的opencart网站出现问题。
The problems are like -
1. When I use http://example.com : It works fine.
2. When I use https://example.com : It works fine with my non-www ssl certificate
3. When I use http://www.example.com : I lose my styles.
4. When I use https://www.example.com : I lose my styles and works as secured page
Now I want it in these ways :
1. When I use http://example.com : It should redirect to https://example.com
2. When I use http://www.example.com : It should redirect to http://example.com so that I can't lose styles.
3. When I use www.example.com : It should redirect to https://example.com
4. When I use only example.com : It should redirect to https://example.com
这是我目前的.htaccess.txt
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/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_=$1 [L,QSA]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]
请指导我如何实现我想要的以及如何解决样式问题。 在此先感谢!
答案 0 :(得分:0)
试试这个(替换.htaccess文件的最后三行):
RewriteCond %{HTTPS} on
RewriteCond %{HTTP:X-Forwarded-SSL} on
RewriteCond %{REQUEST_URI} !^/checkout/?.*$
RewriteRule ^(.*)$ http://url.com/$1 [R=301,L]
并确保使用正确的https:// URL打开您的opencart SSL设置。
如果上述解决方案不起作用,您只需将www的所有调用重定向到非www url,其中您的网站可以与SSL和样式完美配合。
答案 1 :(得分:0)
您可以尝试我的解决方案。他将于2020年工作。
# Redirect to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mystore\.com [NC]
RewriteRule (.*) http://mystore.com/$1 [R=301,L]