Zarkoeleto
Zarkoeleto

Reputation: 133

Yii2 CRUD url issue

My Yii2 app is based on advanced template. I created CRUD for a model named News in backend side.

Now when I try to open

/localhost/backend/web/index.php?r=News

getting Unable to resolve the request News.

Not Found (#404)

Unable to resolve the request "News".

here is the structure:

backend

 models
   News

 controllers
   NewsController

 Views
   News
     index
     _form
     _search
     create
     update
     view

the url /localhost/backend/web/index.php?r=News

What am I doing wrong?

Upvotes: 0

Views: 718

Answers (2)

Kevin Dantas
Kevin Dantas

Reputation: 158

As Mihai P said the problem is probably because of the case sensitive, but if you for some reason need of the uppercase letter, you can just change you config/main.php file like that:

'components' => [
        'urlManager'=>[
            'rules'=>[
                'News'=>'/news',
            ],
            'enablePrettyUrl'=>true,
        ],
        ...

Then you url will loo like /backend/web/index.php/News, if you want to remove the index.php take a look on that link that give you some ways to do that.

Upvotes: 0

Mihai P.
Mihai P.

Reputation: 9357

Try /localhost/backend/web/index.php?r=news it is case sensitive.

Upvotes: 1

Related Questions