php - Symfony /sitemap.xml route inaccessible
one text
In a symfony 5 app, i have a route @Route("/sitemap.xml", name="sitemap", defaults={"_format"="xml"})
When i try to access this route, symfony look for the sitemap file, not the route.
How can i force the route call, not the file?
My controller :
class SitemapController extends AbstractController
{
/**
* @Route("/sitemap.xml", name="sitemap", defaults={"_format"="xml"})
*/
public function index(Request $request)
{
$urls = [];
...
$response = new Response(
$this->renderView('sitemap/index.html.twig', ['urls' => $urls,
'hostname' => $hostname]),
200
);
$response->headers->set('Content-Type', 'text/xml');
return $response;
}
}
Source