site relative links for Prestashop 1.6

To enable site relative links for Prestashop 1.6 you can use the following overrides:
Caution: this is only a quick hack,don’t use in production!

Download the zipped source here

/override/classes/Link.php

<?php
class Link extends LinkCore
{
protected function getBaseLink($id_shop = null, $ssl = null, $relative_protocol = false)
{
static $force_ssl = null;
if ($ssl === null) {
if ($force_ssl === null) {
$force_ssl = (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'));
}
$ssl = $force_ssl;
}
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null) {
$shop = new Shop($id_shop);
} else {
$shop = Context::getContext()->shop;
}
if ($relative_protocol) {
$base = '//'.($ssl && $this->ssl_enable ? $shop->domain_ssl : $shop->domain);
} else {
$base = (($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain);
}
#/** only add base on ssl links */
return (Configuration::get('PS_SSL_ENABLED')&&$ssl?$base:'').$shop->getBaseURI();
}
}

/override/classes/controller/FrontController.php

<?php
class FrontController extends FrontControllerCore
{
/**
* Redirects to canonical URL
*
* @param string $canonical_url
*/
protected function canonicalRedirection($canonical_url = '')
{
if (!$canonical_url || !Configuration::get('PS_CANONICAL_REDIRECT') || strtoupper($_SERVER['REQUEST_METHOD']) != 'GET' || Tools::getValue('live_edit')) {
return;
}
$match_url = rawurldecode(Tools::getCurrentUrlProtocolPrefix().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
if (!preg_match('/^'.Tools::pRegexp(rawurldecode($canonical_url), '/').'([&?].*)?$/', $match_url)) {
$params = array();
$url_details = parse_url($canonical_url);
if (!empty($url_details['query'])) {
parse_str($url_details['query'], $query);
foreach ($query as $key => $value) {
$params[Tools::safeOutput($key)] = Tools::safeOutput($value);
}
}
$excluded_key = array('isolang', 'id_lang', 'controller', 'fc', 'id_product', 'id_category', 'id_manufacturer', 'id_supplier', 'id_cms');
foreach ($_GET as $key => $value) {
if (!in_array($key, $excluded_key) && Validate::isUrl($key) && Validate::isUrl($value)) {
$params[Tools::safeOutput($key)] = Tools::safeOutput($value);
}
}
$str_params = http_build_query($params, '', '&');
if (!empty($str_params)) {
$final_url = preg_replace('/^([^?]*)?.*$/', '$1', $canonical_url).'?'.$str_params;
} else {
$final_url = preg_replace('/^([^?]*)?.*$/', '$1', $canonical_url);
}
/** Don't redirect to same url */
#print "orig: ".$_SERVER['REQUEST_URI']." final: ".$final_url."\n";
if($_SERVER['REQUEST_URI']==$final_url) return;
// Don't send any cookie
Context::getContext()->cookie->disallowWriting();
if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) {
$buri = $_SERVER['REQUEST_URI'];
#var_dump($_SERVER);
die('[Debug] This page has moved '.$buri.' '. __PS_BASE_URI__.'<br />Please use the following URL instead: <a href="'.$final_url.'">'.$final_url.'</a>');
}
$redirect_type = Configuration::get('PS_CANONICAL_REDIRECT') == 2 ? '301' : '302';
header('HTTP/1.0 '.$redirect_type.' Moved');
header('Cache-Control: no-cache');
Tools::redirectLink($final_url);
}
}
}

Download the zipped source here