簡體   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