Error 404 page not found with TwoWordController


(Patrice) #1

I have a rest api

for a simple word action, there is no problem.

Ex : EmailController -> rest api : api/emails, no problem

But for multipleWords an error 404 page not found.

Ex : EmailTemplateController -> rest api : api/emailtemplates, error 404

Any idea how to solve this issue ?

thanks


(Patrice) #2

I reply to myself.

I found a way

in app/config/web.php

You can add a rule :




$config = [

  ...

  'components' => [

    'urlManager' => [

      'enablePrettyUrl' => true,

      'enableStrictParsing' => true,

      'showScriptName' => false,

      'rules' => [

        ...

        [

          'class' => 'yii\rest\UrlRule',

          'pluralize' => false,

          'controller' => ['emailtemplates' => 'email-template'], // email-template refers to EmailTemplateController

        ],

        ...

      ]

      ...

    ]

    ...

  ]

  ...

]




(Stefano Mtangoo) #3

Should be

EmailTemplateController -> rest api :[b] api/email-templates

[/b]