【问题标题】:category url without https redirect to homepage in magento没有https的类别url重定向到magento中的主页
【发布时间】:2015-02-26 07:19:28
【问题描述】:

我们在我们的网站中启用了 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 中

现在这个 url http://www.testsite.com/category.html 重定向到 https://www.testsite.com/category.html。 但是对于这个 url http://testsite.com/category.html,它会重定向到主页。我认为需要对上述代码进行一些调整。请问有人可以帮我吗?

【问题讨论】:

    标签: php .htaccess magento mod-rewrite redirect


    【解决方案1】:

    看起来您只是在尝试强制使用 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]
    

    如果您只想重定向特定的子目录或页面,只需将路径附加到上述条件和规则即可。

    【讨论】:

      猜你喜欢
      • 2017-10-02
      • 2013-04-09
      • 1970-01-01
      • 2014-10-21
      • 1970-01-01
      • 1970-01-01
      • 2017-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多