CI框架去除index.php

  1. 打开apache的配置文件,conf/httpd.conf :
    1. LoadModule rewrite_module modules/mod_rewrite.so
    把该行前的#去掉。
    搜索 AllowOverride None(配置文件中有多处),看注释信息,将相关.htaccess的该行信息改为:
    1. AllowOverride All 
  2. 在CI的根目录下,即在index.php,system的同级目录下,建立.htaccess,直接建立该文件名的不会成功,可以先建立记事本文件,另存为该名的文件即可。内容如下(CI手册上也有介绍):
    1. RewriteEngine on
      RewriteCond $1 !^(index\.php|images|robots\.txt)
      RewriteRule ^(.*)$ /index.php/$1 [L]
    如果不在根目录下:
    1. RewriteEngine on
      RewriteCond $1 !^(index\.php|images|robots\.txt)
      RewriteRule ^(.*)$ /目录/index.php/$1 [L]
  3. 将CI中配置文件(application/config/config.php)中
    1. $config['index_page'] = "index.php";
    改成:
    1. $config['index_page'] = "";
  4. 重启apache,完成。
posted @ 2017-02-04 15:59  青丝锁刘peng  阅读(1951)  评论(3编辑  收藏  举报