簡體   English   中英

不帶https的類別URL重定向到magento中的主頁

[英]category url without https redirect to homepage in magento

我們在網站上啟用了https,並在管理部分啟用了301。

但是問題在於類別網址。 假設我們選擇http:// www.testsite.com/ category.html,它將重定向到主頁。 因此,經過一番搜索,我找到了一個解決方案,告訴我要添加

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https:// %{HTTP_HOST}%{REQUEST_URI} [L,R=301]


RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] .htaccess中的RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

現在,此URL http:// www.testsite.com/ category.html重定向到https:// www.testsite.com/ category.html。 但是對於此URL http:// testsite.com/ category.html,它將重定向到主頁。 我認為需要對上述代碼進行一些調整。 有人可以幫我嗎。

看起來您只是在嘗試強制WWW和HTTPS。 盡管通常應在虛擬主機配置中完成此操作,但我可以理解這是否不是一種選擇。

解決方案很簡單,如下所示:

# Start the Rewrite Engine
RewriteEngine On

#Set the base url to / unless you're in a subdirectory, so not modify this.
RewriteBase /

#Redirect all requests to WWW.
RewriteCond %{HTTP_HOST} ^testsite\.com
RewriteRule (.*) http://www.testsite.com/$1 [R=301,L]

# If requests are made on port 80, rewrite to HTTPS which will server over port 443.
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://testsite.com/$1 [R,L]

如果您只想重定向特定的子目錄或頁面,只需將路徑追加到上述條件和規則即可。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM