Yii2:-Pretty URL's are formed, but not working (says 404 “NOT FOUND”)

前端 未结 3 891
夕颜
夕颜 2020-12-28 21:42

I have started learning yii2 and I tried to do pretty URL stuff, but failed. What I did:-

in config/web.php (I have edited below):

\         


        
3条回答
  •  一生所求
    2020-12-28 22:23

    Why dont you just give the rules in your web.php file? like below:

    'urlManager' => [
            'class' => 'yii\web\UrlManager',
            // Disable index.php
            'showScriptName' => false,
            // Disable r= routes
            'enablePrettyUrl' => true,
            'rules' => array(
                    '/' => '/view',
                    '//' => '/',
                    '/' => '/',
            ),
        ],
    

    The rules i set here is only an example, you can set it the way you want your url to look like.

    EDIT: If its not still working, try to set a virtualhost instead with:

    
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
        Allow from 127.0.0.1 localhost
    
    

提交回复
热议问题