2013-08-04

Yii 在網址列隱藏 index.php

Yii 在網址列隱藏 index.php
參考 http://www.yiiframework.com/wiki/214/url-hide-index-php/

.htaccess 檔的內容使用
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

config/main.php 修改內容
'urlManager'=>array(
    'urlFormat'=>'path',
    'rules'=>array(
      '<controller:\w+>/<id:\d+>'=>'<controller>/view',
      '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
      '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
    ),
    'showScriptName'=>false,
    'caseSensitive'=>false,
),

沒有留言:

FB 留言