您的位置:首页 > 编程语言 > PHP开发

使用URL重写,去掉index.php

2011-12-19 10:05 405 查看
1、在httpd.conf中打开apache的rewrite模块

#LoadModule rewrite_module modules/mod_rewrite.so

将前面的“#”去掉

将“AllowOverride None”改为“AllowOverride All

2、在你的app根目录下创建.htaccess内容如下:

<IfModule mod_rewrite.c>

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

</IfModule>


3、修改config/main.php,在刚才UrlManager组件增加属性showScriptName,值为false.

'urlManager'=>array(

'urlFormat'=>'path', //使用pathinfo模式

'showScriptName'=>false,//不显示脚本名

),


4、重启apache
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: