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

问题描述 投票:2回答:4

我已经安装了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的文本文档。

提前感谢。

php .htaccess redirect opencart
4个回答
3
投票

[最后一个;)

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

在文件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]

问候,


0
投票

这是解决方案:

 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 =否

问候,


0
投票

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

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

首先放入该文件RewriteEngine开启

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]

并且,在管理面板中:

系统->设置->服务器-> ssl =否系统->设置->服务器->网址SEO->是

请再试一次:)问候,


0
投票

将此代码添加到.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>
© www.soinside.com 2019 - 2024. All rights reserved.