D
D
Dmitry Kulikov2016-01-22 12:20:26
Yii
Dmitry Kulikov, 2016-01-22 12:20:26

How to properly redirect requests in yii2?

The site has a page that looks like
/path/aliase
I want to make it go to /path/ and /path Redirect to /path/aliase
This code:

'/path/aliase' => 'controller/action1',
'/path/' => 'controller/action2',

Where action2 has a redirect code
Solves the problem only partially
/path Handled by URlManager And redirects to
/path/ No
How can I fix this behavior?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pozdnyakov, 2016-01-24
@Afinogen

I solved this problem with htaccess

RewriteBase /
    RewriteCond %{HTTP_HOST} (.*)
    RewriteCond %{REQUEST_URI} /$ [NC]
    RewriteRule ^(.*)(/)$ $1 [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question