Answer the question
In order to leave comments, you need to log in
CNC.How to change the url?
There is a plugin that now generates the following link for the page of a separate event:
site.ru/groups/group-name/event/1
how to make the pages have a link of the following form:
site.ru/groups/group-name/name-event
first thought. .create a slug from the name of the event, insert it into the database and then pull out the event not by id but by slug (alias)
is this a good solution or is there a better one?
Answer the question
In order to leave comments, you need to log in
They usually do that. This is a classic solution that is used almost everywhere. Use a slug or id.
Something like
In this option, the id and slug will work, so you don’t have to sacrifice anything.
Don't forget to escape the data before passing it to the request.
There is an alternative when the internal table of correspondences url1 -> url2 is stored. This option is less convenient from the developer's point of view, because you have to make a lot of effort to keep it up to date, etc. This option has a plus if implemented correctly - you can store a chain of redirects from the old address to the new one. For example, if your page received a new address 3 times, then this table will have 4 redirect options. One current and 3 obsolete. In this case, when you go to the old address, a redirect to the new one will occur. Maintaining such a registry of links is not very convenient, but it is suitable for applications at the level of large companies that cannot afford to send the client to a blank page.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question