Yii:隐藏index.php
2011-08-21 00:26:16| 分类: YII Framework |字号 订阅
去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符号;
2. 修改 apache 的 AllowOverride
把 AllowOverride None 修改为 AllowOverride All;
3. 修改 Yii 配置信息的 urlManager
在项目中的/protected/config/main.php中添加以下配置信息:
'components'=>array(
......
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false, // false不需要引号
'urlSuffix'=>'.html',
'rules'=>array(
'sites'=>'site/index',
......
),
),
......
),
4. 在与index.php文件同级目录下添加文件“.htaccess”
Options +FollowSymLinks
IndexIgnore */*
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