Setting my base_url to HTTPS drops the query string
I set the base URL for my site to https://www.example.com
, now when user comes to my site from a non secure URL (link) that has a query at the end of it (http://www.example.com/path/to/page?foo=555&bar=444
) it gets redirected to the https page (https://www.example.com/path/to/page
), however the queries get removed :-( I need them to stay, so the final URL would be https://www.example.com/path/to/page?foo=555&bar=444
I found in the Mage_Core_Controller_Varien_Router_Standard
class there is a method (line 441) _checkShouldBeSecure
that sets the redirect to secure
protected function _checkShouldBeSecure($request, $path = '') {
if (!Mage::isInstalled() || $request->getPost()) {
return;
}
if ($this->_shouldBeSecure($path) && !$request->isSecure()) {
$url = $this->_getCurrentSecureUrl($request);
if ($request->getRouteName() != 'adminhtml' && Mage::app()->getUseSessionInUrl()) {
$url = Mage::getSingleton('core/url')->getRedirectUrl($url);
}
Mage::app()->getFrontController()->getResponse()
->setRedirect($url)
->sendResponse();
exit;
}
}
i want to make a local override and add this line
if ($_SERVER['QUERY_STRING']) {$url .= '?'.$_SERVER['QUERY_STRING'];};
Is that safe? will it cause any problems? is there a better way for me to go about preserving the query string?