HT 访问问题
我的 opencart SSL (https) 电子商务网站存在以下问题。当我在谷歌上搜索我的网站时,它默认为 https://ricambimoto.uk 这会导致一些字体很棒的图标在清除缓存的情况下首次加载浏览器时不会显示。如果我刷新浏览器页面,它会将 URL 更改为 https://www.ricambimoto.uk 并且一切正常。我的 ReWrite 部分中的 htaccess 文件如下:
RewriteBase /
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
RewriteRule ^sitemap.xml$ index.php?route=extension/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]
这里是否存在明显的错误,因为我看不到可能导致该错误的原因?我需要强制 URL 每次都添加 www 元素。
我应该补充一点,我还修改了 root 和 admin 配置文件,如下
root config.php
// HTTP
define('HTTP_SERVER', 'https://www.ricambimoto.uk/');
// HTTPS
define('HTTPS_SERVER', 'https://www.ricambimoto.uk/');
admin config.php
// HTTP
define('HTTP_SERVER', 'https://www.ricambimoto.uk/admin/');
define('HTTP_CATALOG', 'https://www.ricambimoto.uk/');
// HTTPS
define('HTTPS_SERVER', 'https://www.ricambimoto.uk/admin/');
define('HTTPS_CATALOG', 'https://www.ricambimoto.uk/');
I have an opencart SSL (https) ecommerce site with the following issue. When I search on google for my site it defaults to https://ricambimoto.uk which causes some of the font awesome icons not to show up on first loading the browser with the cache cleared. If I refresh the browser page it changes the URL to https://www.ricambimoto.uk and all is well. My htaccess file in the ReWrite section is as follows:
RewriteBase /
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
RewriteRule ^sitemap.xml$ index.php?route=extension/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]
Is there a glaring error here as I can't see what could be causing it? I need to force the URL to add the www element every time.
I should add that I have amended the root and admin config files as follows as well
root config.php
// HTTP
define('HTTP_SERVER', 'https://www.ricambimoto.uk/');
// HTTPS
define('HTTPS_SERVER', 'https://www.ricambimoto.uk/');
admin config.php
// HTTP
define('HTTP_SERVER', 'https://www.ricambimoto.uk/admin/');
define('HTTP_CATALOG', 'https://www.ricambimoto.uk/');
// HTTPS
define('HTTPS_SERVER', 'https://www.ricambimoto.uk/admin/');
define('HTTPS_CATALOG', 'https://www.ricambimoto.uk/');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试强制非
www
。添加到您的.htaccess
文件:Try to force non
www
. Add to your.htaccess
file:第一行(
RewriteCond
指令)中应该是HTTP_HOST
,而不是HTTPS_HOST
(它不存在)。然而,正如所写,这应该会产生无限的重定向循环?并且您的规则中的
route
和_route_
URL 参数之间存在不一致。整个网站的 URL 使用/index.php?route=
形式,不需要.htaccess
。这让我想知道您的 .htaccess 文件是否实际上在做任何事情?It should be
HTTP_HOST
in the first line (RewriteCond
directive), notHTTPS_HOST
(which doesn't exist).However, as written, this should have generated an endless redirect-loop? And you have inconsistencies between a
route
and_route_
URL parameter in your rules. And the URLs throughout your site use the form/index.php?route=<page>
which doesn't require.htaccess
. This makes me wonder whether your.htaccess
file is actually doing anything?