['file' => 'sp_redirects.php', 'target' => 'superpro-suspension.com/us/', 'sameStoreRedirect' => false], 'ukwhitelineperformance.com' => ['file' => 'wl_uk_redirects.php', 'target' => 'whitelineperformance.com/uk/', 'sameStoreRedirect' => false], 'whitelineperformance.com' => ['file' => 'wl_us_redirects.php', 'target' => 'whitelineperformance.com/us/', 'sameStoreRedirect' => true], 'nolathane.com.au' => ['file' => 'nl_au_redirects.php', 'target' => 'nolathane.com/au/', 'sameStoreRedirect' => false], 'nolathane.com' => ['file' => 'nl_us_redirects.php', 'target' => 'nolathane.com/us/', 'sameStoreRedirect' => true] ]; foreach ($redirectDomainMapping as $domain => $redirectDomains) { if (strpos($_SERVER['HTTP_HOST'], $domain) !== false) { require __DIR__ . '/' . $redirectDomains['file']; $newUrl = 'https://' . $redirectDomains['target']; if (isset($redirects)) { $requestUri = trim($_SERVER["REQUEST_URI"] ?? "", "/"); $pathOnly = explode("?", $requestUri)[0]; $queryStr = $_SERVER["QUERY_STRING"] ?? ""; $fullPath = $queryStr ? $pathOnly . "?" . $queryStr : $pathOnly; $path = isset($redirects[$fullPath]) ? $fullPath : $pathOnly; if (isset($redirects[$path])) { // if start with https:// use it as full url if (strpos($redirects[$path], 'https://') === 0) { $newUrl = $redirects[$path]; } else { $newUrl .= $redirects[$path]; } header('Location: ' . $newUrl, true, 301); exit(); } else if (!$redirectDomains['sameStoreRedirect']) { header('Location: ' . $newUrl, true, 301); exit(); } } break; } } if (!isset($_SERVER[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE])) { if(strpos($_SERVER['HTTP_HOST'],"fulcrumsuspensions") !== false){ $code = 'default'; } elseif(strpos($_SERVER['HTTP_HOST'],"formula4x4.co.za") !== false){ $code = 'formula_za'; } elseif(strpos($_SERVER['HTTP_HOST'],"formula") !== false){ $code = 'formula'; } elseif(strpos($_SERVER['HTTP_HOST'],"superpro") !== false){ $code = 'superpro_au'; } elseif(strpos($_SERVER['HTTP_HOST'],"whitelineperformance") !== false){ $code = 'whiteline_us'; } else if (str_contains($_SERVER['HTTP_HOST'], "nolathane")){ $code = 'nolathane_au'; } else { $code = 'whiteline'; } $_SERVER[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = $code; $_SERVER[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store'; } } catch (\Exception $e) { echo <<
{$e->getMessage()}
HTML; http_response_code(500); exit(1); } $bootstrap = Bootstrap::create(BP, $_SERVER); /** @var \Magento\Framework\App\Http $app */ $app = $bootstrap->createApplication(\Magento\Framework\App\Http::class); $bootstrap->run($app);