欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

magento 让某个页面开启SSL访问

发布时间:2024/9/20 43 豆豆
生活随笔 收集整理的这篇文章主要介绍了 magento 让某个页面开启SSL访问 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

2019独角兽企业重金招聘Python工程师标准>>>

比如带有creditcard-pay的url页面,修改下面几处,具体方法作用可以看注释
\app\code\core\Mage\Core\Model\Store.php

    /*** Check if frontend URLs should be secure** @return boolean*/public function isFrontUrlSecure(){$pathInfo = Mage::app()->getRequest()->getPathInfo();//byfengif('/creditcard-pay'==$pathInfo){return true;}if ($this->_isFrontSecure === null) {$this->_isFrontSecure = Mage::getStoreConfigFlag(Mage_Core_Model_Url::XML_PATH_SECURE_IN_FRONT,$this->getId());} return $this->_isFrontSecure;}

\app\code\core\Mage\Core\Model\Design\Package.php

    /*** Prepare url for css replacement** @param string $uri* @return string*/protected function _prepareUrl($uri){// check absolute or relative urlif (!preg_match('/^https?:/i', $uri) && !preg_match('/^\//i', $uri)) {$fileDir = '';$pathParts = explode(DS, $uri);$fileDirParts = explode(DS, $this->_callbackFileDir);$store = $this->getStore();if ($store->isAdmin()) {$secure = $store->isAdminUrlSecure();} else {$secure = $store->isFrontUrlSecure() && Mage::app()->getRequest()->isSecure();}$pathInfo = Mage::app()->getRequest()->getPathInfo(); if('/creditcard-pay'==$pathInfo){$secure = true;}if ('skin' == $fileDirParts[0]) {$baseUrl = Mage::getBaseUrl('skin', $secure);//byfeng 合并css文件里的url https$fileDirParts = array_slice($fileDirParts, 1);} elseif ('media' == $fileDirParts[0]) {$baseUrl = Mage::getBaseUrl('media', $secure);$fileDirParts = array_slice($fileDirParts, 1);} else {$baseUrl = Mage::getBaseUrl('web', $secure);}foreach ($pathParts as $key=>$part) {if ($part == '.' || $part == '..') {unset($pathParts[$key]);}if ($part == '..' && count($fileDirParts)) {$fileDirParts = array_slice($fileDirParts, 0, count($fileDirParts) - 1);}}if (count($fileDirParts)) {$fileDir = implode('/', $fileDirParts).'/';}$uri = $baseUrl.$fileDir.implode('/', $pathParts);}return $uri;}

\app\Mage.php

    /*** Get base URL path by type** @param string $type* @param null|bool $secure* @return string*/public static function getBaseUrl($type = Mage_Core_Model_Store::URL_TYPE_LINK, $secure = null){$pathInfo = self::app()->getRequest()->getPathInfo(); if('/creditcard-pay'==$pathInfo){$secure = true;}return self::app()->getStore()->getBaseUrl($type, $secure);}

 

cloudflare flexible SSL 情况 // 后台也要https

1. Mage_Core_Model_Url 

public function getSecure()

$this->setData('secure', true);

2. Mage_Core_Model_Store

public function isFrontUrlSecure()

return true;

3. 后台设置

Unsecure项  skin、media、js,都得用https

// 后台 https

Mage_Adminhtml_Model_Url

public function getSecure()

return true;

Mage_Adminhtml_Block_Media_Uploader

return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true)...;

转载于:https://my.oschina.net/liufeng815/blog/362021

总结

以上是生活随笔为你收集整理的magento 让某个页面开启SSL访问的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。