0

I have an old website, now I have written it with new version of yii framework and I want change the urls, but because of SEO problems I want to keep my old urls. Now when the user enters www.mysite.pre/car/details/10908 I want application renders www.mysite.pre/site/show_detail/10908 how could I handle it in yii2 Routing?

0

1 Answer 1

1

Assuming you have got this action in your SiteController class

public function actionShow_detail($id) {}

Add this in your configuration file:

// ...
'components' => [
    // ...
    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName'  => false,
        'rules'           => [
            // ...
            'car/details/<id:\d+>' => 'site/show_detail',
        ],
    ],
],

More details and information about Yii 2 routing can be found in "Routing and URL Creation" section of The Definitive Guide to Yii 2.0.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.