Yii Framework Forum: Error 404 page not found with TwoWordController - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Error 404 page not found with TwoWordController Problem with lower / upper case and plural ?

#1 User is offline   flaho 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 22-March 13
  • Location:Paris

Posted 14 June 2018 - 08:23 AM

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
0

#2 User is offline   flaho 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 22-March 13
  • Location:Paris

Posted 14 June 2018 - 09:02 AM

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
        ],
        ...
      ]
      ...
    ]
    ...
  ]
  ...
]

0

#3 User is offline   Stefano Mtangoo 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 378
  • Joined: 02-January 12
  • Location:Dar es Salaam, Tanzania

Posted 18 June 2018 - 01:35 PM

View Postflaho, on 14 June 2018 - 08:23 AM, said:

But for multipleWords an error 404 page not found.
Ex : EmailTemplateController -> rest api : api/emailtemplates, error 404


Should be

EmailTemplateController -> rest api : api/email-templates


And God said, Let there be science...and it was so! Kwa kazi za Mifumo ya Computer tuone tukusaidie hapa!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users