我安装了 opencart 最新版本,我想为 url 启用所有 ssl
在管理员中设置 SSL 启用
在 config.php 中,admin 和 category 都更改为 https
访问权限
RewriteEngine On
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_=$1 [L,QSA]
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
但是当 url 不是 SEO 时它工作所以 url 与 SEO 它不起作用 网址将是 https://www.localhost/index.php?route=desktops/mac
最佳答案
我还安装了 opencart 2.2。
我尝试了 https 的扩展,但它崩溃了;(
我找到了一个可行的解决方案 3 个步骤:
•• 1 •• 在 .htaccess 中:在末尾添加
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} store
RewriteRule ^(.*)$ https://www.__your_domain__.com/store/$1 [R,L]
•• 2 ••
在 root + admin 的 config.php 中
<?php
// HTTP
define('HTTP_SERVER', 'https://www.__your_domain__.com/store/');
// HTTPS
define('HTTPS_SERVER', 'https://www.__your_domain__.com/store/');
**** 即使在浏览器中使用 https://也是不够的....在源代码中每个链接都是 http://.... **** 所以我找到了最后一步
•• 3 •• 在系统/图书馆/网址 将 http 修改为 https 和 voilà :)
public function link($route, $args = '', $secure = false) {
if ($this->ssl && $secure) {
$url = 'https://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/.\\') . '/index.php?route=' . $route;
} else {
$url = 'https://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/.\\') . '/index.php?route=' . $route;
}
关于php - Opencart 2.2.x ssl 用于所有请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36272499/