How to remove index.php in Yii Framework

后端 未结 9 1747
一个人的身影
一个人的身影 2020-12-08 22:56

\"enterHey guyz i am a newbie in Yii framework. I want to remove the index.php from my urls. F

9条回答
  •  情深已故
    2020-12-08 23:39

    change your config/main.php like below:

    'urlManager'=>array(
            'urlFormat'=>'path',
            'showScriptName'=>false,
            'caseSensitive'=>false,
            'rules'=>array(
                '/'=>'/view',
                '//'=>'/',
                '/'=>'/',
            ),
    

    then place your htaccess file on base directory with protected folder (it may be inside protected folder) place below code to your htaccess file

    RewriteEngine on
    
    # if a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # otherwise forward it to index.php
    RewriteRule . index.php
    

    or try with this---

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
    

    done...hope it will work

提交回复
热议问题