Magento getProductUrl () always returns HTTP

Even when I'm on HTTPS, Magento getProductUrl () always returns an HTTP URL. Any ways to make this automatic switch to HTTPS? (or return the relative protocol url to it).

I would say that this is a pretty "standard" configuration.

Base URL http://example.com/

Secure URL https://example.com/

No secure URLs used in Frontend

The base URL of the link {{unsecure_base_url}}

I know that I could change this above to {{secure_base_url}}, but I don’t want to push the changes from HTTP to HTTPS, I need it to remain relative.

+5
source share
4 answers

Magento , , :) , , URL- HTTPS . , , Magento.

HTTPS for frontend , , , .. , HTTPS.

Magento HTTPS , . HTTPS, " URL- " "". , , HTTPS , .

, .

1) HTTPS -, "https://..." " URL" "" -URL.

2) HTTPS , , URL. , , :

echo trim($_product->getProductUrl(),'http:')

3) HTTPS Mage_Catalog_Module_Product_Url - Mage_Catalog_Module_Product_Url getUrl() -

$routeParams['_secure'] = true;

URL HTTPS.

4) HTTP HTTP, HTTPS HTTPS, 3) : _secure.

, .

+13

, :

echo trim($_product->getProductUrl(),'http:')
+1

$product->getProductUrl()

Try

$product->getUrlModel()->getUrl($product, array('_secure'=>(bool)Mage::app()->getStore()->isCurrentlySecure()))

/ URL- .

0

, System | | Web ~, " url in frontend" - yes, , https, https-,

-2

All Articles