Files

47 lines
2.4 KiB
Diff

--- a/classes/shop/Shop.php
+++ b/classes/shop/Shop.php
@@ -411,38 +411,14 @@
} else {
$shop = new Shop($id_shop);
if (!Validate::isLoadedObject($shop) || !$shop->active) {
- // No shop found ... too bad, let's redirect to default shop
- $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
+ // EduBox: behind a reverse proxy with dynamic public domains,
+ // the requested host never matches ps_shop_url. Always use the
+ // default shop instead of redirecting to a fixed canonical URL.
+ $shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
- // Hmm there is something really bad in your Prestashop !
- if (!Validate::isLoadedObject($default_shop)) {
+ if (!Validate::isLoadedObject($shop)) {
throw new PrestaShopException('Shop not found');
}
-
- $params = $_GET;
- unset($params['id_shop']);
- $url = $default_shop->domain;
- if (!Configuration::get('PS_REWRITING_SETTINGS')) {
- $url .= $default_shop->getBaseURI() . 'index.php?' . http_build_query($params);
- } else {
- // Catch url with subdomain "www"
- if (strpos($url, 'www.') === 0 && 'www.' . $_SERVER['HTTP_HOST'] === $url || $_SERVER['HTTP_HOST'] === 'www.' . $url) {
- $url .= $_SERVER['REQUEST_URI'];
- } else {
- $url .= $default_shop->getBaseURI();
- }
-
- if (count($params)) {
- $url .= '?' . http_build_query($params);
- }
- }
-
- $redirect_type = Configuration::get('PS_CANONICAL_REDIRECT');
- $redirect_code = ($redirect_type == 1 ? '302' : '301');
- $redirect_header = ($redirect_type == 1 ? 'Found' : 'Moved Permanently');
- header('HTTP/1.0 ' . $redirect_code . ' ' . $redirect_header);
- header('Location: ' . Tools::getShopProtocol() . $url);
- exit;
} elseif (defined('_PS_ADMIN_DIR_') && empty($shop->physical_uri)) {
$shop_default = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
$shop->physical_uri = $shop_default->physical_uri;