2016-09-26 88 views
1

我有一個問題,我的項目運行在nginx上,所以我不能通過htaccess重定向。解決方案是我需要使用PHP的index.php重定向http到https。Magento index.php 301重定向http到https

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

此外,大多數的對谷歌的例子表明使用htaccess的,這就是爲什麼我在這裏。

+1

'解決方案是我需要使用php使用php將http重定向到https'爲什麼不使用nginx ...?如果你想讓你的前端安全運行,Magento有一個配置設置。 –

+0

沒有訪問權限 – Macas

回答

2
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.s. WWW str替換是這裏不需要的附加功能