I am currently building custom CMS and I am looking to allow slashes ("/") in my URL's. I have found a away of making them work but it does cause problems for other pages.
So I have a page that has a URL http://www.example.com/about-us/meet-the-team and it works perfectly with this on the controller: -
/**
* @Route("{slug}", name="livepages", requirements={"slug"=".+"})
*/
public function livepagesAction(Request $request, $slug)
{
// Some Code Here
}
However, I also have other pages in the Admin section that have URL's such as this http://www.example.com/admin/pages/add . No when I try to visit this page, I get a GET Error. The code is as follows: -
/**
* @Route("admin/pages/add", name="addpages")
*/
public function addpagesAction(Request $request)
{
// Some Code Here
}
It's worth mentioning that the /about-us/meet-the-team slug is stored in the database as is.
I've tried a few methods to overcome this and it has caused a few issues. Can anyone help me with some ideas?
将slug
route放置在routing.yml
配置文件的末尾,以便路由系统将首先检查其他路由,如果没有匹配,它将调用slug
route
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.