вы можете получить реферера и попытаться "сопоставить" его со службой маршрутизации, чтобы увидеть, существует ли маршрут для этого пути:
$referer = $request->headers->get('referer'); // get the referer, it can be empty!
if (!\is_string($referer) || !$referer) {
echo 'Referer is invalid or empty.';
return;
}
$refererPathInfo = Request::create($referer)->getPathInfo();
// try to match the path with the application routing
$routeInfos = $this->router->match($refererPathInfo);
// get the Symfony route name if it exists
$refererRoute = $routeInfos['_route'] ?? '';
Извлеките полный фрагмент моего блога .