HT 访问问题

发布于 2025-01-16 22:44:19 字数 1612 浏览 6 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

向地狱狂奔 2025-01-23 22:44:19

尝试强制非 www。添加到您的 .htaccess 文件:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Try to force non www. Add to your .htaccess file:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
子栖 2025-01-23 22:44:19
RewriteCond %{HTTPS_HOST} !^www\.
重写规则 ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

第一行(RewriteCond 指令)中应该是 HTTP_HOST,而不是 HTTPS_HOST(它不存在)。

然而,正如所写,这应该会产生无限的重定向循环?并且您的规则中的 route_route_ URL 参数之间存在不一致。整个网站的 URL 使用 /index.php?route= 形式,不需要 .htaccess。这让我想知道您的 .htaccess 文件是否实际上在做任何事情?

RewriteCond %{HTTPS_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

It should be HTTP_HOST in the first line (RewriteCond directive), not HTTPS_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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文