Configuration > Smart Links Settings): the call is redirected to * the link's destination — its external URL, or its landing page / standalone form for * Mautic redirects — with its UTM parameters, and one hit is recorded for the statistics. * On any other host, unknown slug, unpublished link or link without destination the * short link doesn't exist: 404. */ class PublicController extends CommonController { private SmartLinkModel $smartLinkModel; #[Required] public function autowirePublicController(SmartLinkModel $smartLinkModel): void { $this->smartLinkModel = $smartLinkModel; } public function goAction(Request $request, string $slug): Response { // The "if and only if" rule: only the short link domain is an entry point for /l/. $domain = $this->smartLinkModel->getShortLinkDomain(); if ('' === $domain || 0 !== strcasecmp(trim($request->getHost()), $domain)) { return $this->notFound(); } $slug = trim($slug); if ('' === $slug) { return $this->notFound(); } $link = $this->smartLinkModel->getRepository()->findOneBy(['slug' => $slug]); if (null === $link || !$link->isPublished()) { return $this->notFound(); } // A link without destination goes nowhere, whatever its type. if ($link->getRedirectType()->isMautic()) { if (null === $link->getPage() && null === $link->getForm()) { return $this->notFound(); } } elseif ('' === trim((string) $link->getDestinationUrl())) { return $this->notFound(); } try { $this->smartLinkModel->recordHit($link, $request); } catch (\Throwable $e) { // Statistics must never block the redirect. error_log('Smart Link hit could not be recorded for slug "'.$slug.'": '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine()); } return new RedirectResponse($this->smartLinkModel->buildRedirectUrl($link), $link->getRedirectCode()->value); } }