0

I have an action name cart in site controller and I have used pretty URL so my URL is

WWW.test.com/cart

But I want to redirect if someone enter WWW.test.com/cart/, then it should be redirected to WWW.test.com/cart. I don't have cart controller.

rob006
  • 21,383
  • 5
  • 53
  • 74
rAnA bilAl
  • 36
  • 4
  • 1
    If you are saying you want to remove the trailing slash, you have a choice to make, here you will find some options for a solution: https://github.com/samdark/yii2-cookbook/blob/master/book/handling-trailing-slash-in-urls.md – dataskills Mar 01 '19 at 21:04

1 Answers1

0

You need to use UrlNormalizer for that:

'urlManager' => [
    // ...
    'normalizer' => [
        'class' => yii\web\UrlNormalizer::class,
    ],
],

See documentation about URL normalization for more info.

rob006
  • 21,383
  • 5
  • 53
  • 74