我已经安装了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网址重定向到http。我还检查了opencart中的config.php文件,它不包含任何https网址。
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的文本文档。
提前致谢。
答案 0 :(得分: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]
的问候,
答案 1 :(得分: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]
并且,在管理面板中:
系统 - &GT;设置 - &GT;服务器 - &GT; ssl = NO
此致
答案 2 :(得分:0)
创建一个新文件.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]
并且,在管理面板中:
系统 - &GT;设置 - &GT;服务器 - &GT; ssl = NO 系统 - &GT;设置 - &GT;服务器 - &GT; Url SEO - &gt;是
请再试一次:) 的问候,
答案 3 :(得分: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>