php - Take out the "public" part from URL from Symfony
one text
Solution:
Your route 'video_list' is to FrontController::videoList
is declared in the annotation:
/**
* @Route("/public/video-list", name="video_list")
*/
public function videoList()
{
return $this->render('front/video_list.html.twig');
}
You have annotated your class method FrontController::videoList
to be a route named "video_list" and has a path "/public/video-list". To remove the "/public" part from the route path, simply modify the @Route
parameter accordingly:
/**
* @Route("/video-list", name="video_list")
*/
public function videoList()
{
return $this->render('front/video_list.html.twig');
}
Then you should then use the "cache:clear" command to refresh the cache of your annotations. Then the generated path should be changed.
You may use the "debug:router" command to see if the result matches the change.
Source