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
本文介绍如何在Yii框架中隐藏index.php文件,实现更美观的URL。主要包括:启用Apache的mod_rewrite模块、修改Apache配置允许覆盖、调整Yii配置文件中的URL管理器设置以及创建.htaccess文件。
129

被折叠的 条评论
为什么被折叠?



