2014年1月4日 星期六

Yii remove the index.php

1. create a file .htaccess and put it in your project root folder
.htaccess
-------------------------------------------------
RewriteEngine On
RewriteBase /project123                    //change this to your folder e.g. localhost/project123
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

config/main.php

//urlManager rules
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
'rules'=>array( // customize rules for your application
//'<controller:\w+>/<id:\d+>'=>'<controller>/view',    // comment this
//'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
//'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',    // comment this
),
),

Example:

for further examples please read
http://www.yiiframework.com/doc/blog/1.1/en/final.url





沒有留言:

張貼留言