Dziękuję bardzo za podpowiedź powyżej. Zintegrowałem kod w "module podobnym do Magento" bez przeciążania Rdzenia.
Istnieją tylko trzy pliki, aby utworzyć:
app/code/local/MyCompany/MyModule/Controller/Varien/Router/Standard.php
app/code/local/MyCompany/MyModule/etc/config.xml
app/etc/modules/MyCompany_MyModule.xml
W app/etc/modules/MyCompany_MyModule.xml
wklej następujący nieciekawe rzeczy:
<?xml version="1.0"?>
<config>
<modules>
<MyCompany_MyModule>
<active>true</active>
<codePool>local</codePool>
</MyCompany_MyModule>
</modules>
</config>
W app/code/local/MyCompany/MyModule/etc/config.xml
wklej router konfiguracja:
<?xml version="1.0"?>
<config>
<modules>
<MyCompany_MyModule>
<version>0.1.0</version>
</MyCompany_MyModule>
</modules>
<default>
<web>
<routers>
<standard>
<area>frontend</area>
<class>MyCompany_MyModule_Controller_Varien_Router_Standard</class>
</standard>
</routers>
</web>
</default>
</config>
I w app/code/local/MyCompany/MyModule/Controller/Varien/Router/Standard.php
zaimplementuj logikę z powyżej:
<?php
class MyCompany_MyModule_Controller_Varien_Router_Standard extends Mage_Core_Controller_Varien_Router_Standard {
protected function _checkShouldBeSecure($request, $path='') {
parent::_checkShouldBeSecure($request, $path);
if (!$this->_shouldBeSecure($path) && Mage::app()->getStore()->isCurrentlySecure()) {
$url = $this->_getCurrentUnsecureUrl($request);
Mage::app()->getFrontController()->getResponse()
->setRedirect($url)
->sendResponse();
exit;
}
}
protected function _getCurrentUnsecureUrl($request) {
if ($alias = $request->getAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS)) {
return Mage::getBaseUrl('link', false).ltrim($alias, '/');
}
return Mage::getBaseUrl('link', false).ltrim($request->getPathInfo(), '/');
}
}
Niestety nie było obserwować wydarzenie, które stały problem ... Ale nadrzędne router jest lepsza (aktualizacje) niż (technicznie) zastępując.
Cheers bogate prostu okazało się, że. –