/** * Gets the active domain, and sets its URL to the native one, with a vanity * URL in the request * * @param SS_HTTPRequest $request * @param Session $session * @param DataModel $model */ public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model) { if (Director::is_cli()) { return; } // Not the best place for validation, but _config.php is too early. if (!MultiDomain::get_primary_domain()) { throw new Exception('MultiDomain must define a "' . MultiDomain::KEY_PRIMARY . '" domain in the config, under "domains"'); } foreach (MultiDomain::get_all_domains() as $domain) { if (!$domain->isActive()) { continue; } $url = $this->createNativeURLForDomain($domain); $parts = explode('?', $url); $request->setURL($parts[0]); } }