繁体   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