繁体   English   中英

Magento index.php 301将http重定向到https

[英]Magento index.php 301 redirect http to https

我有一个问题,我的项目正在nginx上运行,所以我无法通过htaccess进行重定向。 解决方案是我需要使用使用PHP的index.php将http重定向到https。

http://example.com/shoeshttps://example.com/shoes

另外,谷歌上的大多数示例都建议使用htaccess,这就是为什么我在这里。

if(!$_SERVER['HTTPS'] || strtolower($_SERVER['HTTPS']) != 'on' ){
    header("HTTP/1.1 301 Moved Permanently");
    header('Location: https://' . str_replace('www.','',$_SERVER['HTTP_HOST']) . $_SERVER['REQUEST_URI']);
    exit();
}

找到了对我有用的解决方案。

ps WWW str替换是此处不需要的其他功能

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM