M
M
Mark2021-05-26 18:48:30
Yii
Mark, 2021-05-26 18:48:30

How to keep only one available route format and set 302 redirect in others in Yii2?

There is a link of the format:
domain.com/catalog/items?slug=some-param - let's call it " Original "

Made it in the following format:
domain.com/catalog/items/some-param - let's call it " Beautiful "

Using the rule in UrlManager :

'catalog/items/<slug:[a-z0-9_\-]+>' => '/catalog/items',


Problem: The
content of the site is available through two links with Original and Beautiful.
I want that there was access only to the Beautiful link. And when switching to the Original one, there was a redirect to the Beautiful one.

How can this be implemented? Perhaps an extended UrlManager rule, or a .htaccess directive (Apache server)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2021-05-28
@MarkLb

This can be implemented using UrlManager. An example can be viewed here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question