magento 让某个页面开启SSL访问
2019独角兽企业重金招聘Python工程师标准>>>
比如带有creditcard-pay的url页面,修改下面几处,具体方法作用可以看注释
\app\code\core\Mage\Core\Model\Store.php
\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访问的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 【转】一篇文章读懂人力资源三支柱体系(C
- 下一篇: 12月中国域名服务商Top20市场份额解