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

Magento index.php 301将http重定向到https,php,http,magento,redirect,https,Php,Http,Magento,Redirect,Https,我有一个问题,我的项目正在nginx上运行,所以我不能通过htaccess进行重定向。解决方案是,我需要使用index.php使用php将http重定向到https 范例 到 此外,谷歌上的大多数例子都建议使用htaccess,这就是我来这里的原因 if(!$_SERVER['HTTPS'] || strtolower($_SERVER['HTTPS']) != 'on' ){ header("HTTP/1.1 301 Moved Permanently"); header('L

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

范例

此外,谷歌上的大多数例子都建议使用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();
}
找到了一个适合我的解决方案


p、 WWW.str replace是这里不需要的附加功能

解决方案是我需要使用index.php使用php将http重定向到https
为什么不使用nginx。。。?如果希望前端安全运行,则Magento具有相应的配置设置。没有访问权限