繁体   English   中英

在 opencart 中使用 htaccess 将 https 重定向到 http

[英]Redirect https to http using htaccess in opencart

我已经安装了 opencart 2.0.1.1,我需要将https://www.domain.com重定向到http://www.domain.com 我如何使用 htaccess 文件实现它。

我已经在 htaccess 文件中尝试过这段代码。 但这不起作用。

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

我应该如何将 https URL 重定向到 http。 我还检查了 opencart 中的 config.php 文件,它不包含任何 https URL。

opencart现有的htaccess文件包含如下代码

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^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]

但该文件不是 htaccess 文件。 它只有一个名为 htaccess.txt 的文本文档。

提前致谢。

最后一个 ;)

您可以尝试放置此代码,为您的域更改

在文件 config.php 和 admin/config.php 中将引用更改为 https,替换“http”。

define('HTTPS_SERVER', 'http S://www.example.com/');
define('HTTPS_IMAGE', 'http S://www.example.com/image/');

代替

define('HTTPS_SERVER', 'http://www.example.com/');
define('HTTPS_IMAGE', 'http://www.example.com/image/');

我的 htaccess 文件:

Options +FollowSymlinks

# Prevent Directoy listing 
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
 Order deny,allow
 Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On

RewriteCond %{HTTP_HOST} ^yourDomain.com
RewriteRule ^ http://yourDomain.com%{REQUEST_URI} [L,R=301]


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 %{HTTP_HOST} ^yourDomain.com
 RewriteRule ^ http://www.yourDomain.com%{REQUEST_URI} [L,R=301]

或者,如果您不喜欢使用 www ,

 RewriteCond %{HTTP_HOST} ^yourDomain.com
 RewriteRule ^ http://yourDomain.com%{REQUEST_URI} [L,R=301]

并且,在管理面板中:

系统->设置->服务器-> ssl=NO

问候,

是的,好吧,我以为你有一个“正确的”htaccess。 请进行以下操作:

创建一个新文件 .htaccess 或将 htaccess.txt 重命名为 .htaccess 。 文件名中的“点”很重要。 “.htaccess”(我建议你重命名文件)

将该文件先放在 RewriteEngine On

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^yourDomain.com
RewriteRule ^ http://www.yourDomain.com%{REQUEST_URI} [L,R=301]

或者,如果您不喜欢使用 www ,

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^yourDomain.com
 RewriteRule ^ http://yourDomain.com%{REQUEST_URI} [L,R=301]

并且,在管理面板中:

system->settings->server->ssl=NO system->settings->server->Url SEO->YES

请再试一次:) 问候,

将此代码添加到 .htaccess 文件中,它应该重定向到您在配置文件中的内容。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM