简体   繁体   中英

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?

尝试/localhost/backend/web/index.php?r=news区分大小写。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM