J
J
jaygen2020-07-07 19:10:38
Laravel
jaygen, 2020-07-07 19:10:38

How to do dynamic routing?

Tell me how to perform dynamic routing ..
For example, now I have routes in a separate file .. and they are strict for example:

'main/index/{page:\d+}' => [
    'controller' => 'main',
    'action' => 'index',
  ],

We get the structure www.ru/main/index/1.
And if the user creates such a structure
1.Category /*www.ru/{category}; /*www.ru/{category}/{post}
-1.1. (Category/subcategory)-/*www.ru/{category}/{category}; /*www.ru/{category}/{category}/{post}
-1.2(Category/subcategory)--/*www.ru/{category}/{category}/{category}; /*www.ru/{category}/{category}/{category}/{post}
- - 1.2.1(Category/subcategory)--/*www.ru/{category}/{category}/{category }/{category}; /*www.ru/{category}/{category}/{category}/{category}/{post}
---1.2.1.1(Category/subcategory) - there are articles /*www.ru/{category}/ {category}/{category}/{category}/{category}; /*www.ru/{category}/{category}/{category}/{category}/{category}/{post}
How to take into account such structures?
the same structure in route you will not think over everything.
How to be in this case

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2020-07-08
@Alex_Wells

Make a rout that matches everything in general, and they will figure it out already in the controller.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question