Reputation: 851
I am developing Yii2 project
where create api module in it but have a issue to call api where got error of page not found.
How to call that api controller which i created. I Run below url for api call.
The requested URL /project/project_name/api/v1/api/login
was not found on this server.
What i have to change or any configuration required
for it. I am missing something anywhere. Any one have experience or trick to solved it.
Thanks in Advance.
Upvotes: 0
Views: 2120
Reputation: 990
Adding below code into my main.php solved the 404 not found issue:
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => false,
'showScriptName' => false,
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => 'user',
],
],
]
I was trying to set enableStrictParsing to true for the urlManager but still the same then try this,
'enableStrictParsing' => false,
Upvotes: 1
Reputation: 1794
It can cause by two reasons:
config/web.php
(Or if this module may run under Command environment, also add to config/console.php
) under modules
key.UrlManager
module on config/web.php
and try for browsing. If it fixed that, you can define a pattern for your url.If any help is needed, please do not hesitate to submit comment on my answer.
Upvotes: 0