Codeigniter - 去除URL中的index.php

在Codeigniter中默认url的形式:http://huangjacky.com/index.php/controller/action/param1/param2,那么如何去掉这个url中的index.php呢?其实我们只需要在根目录创建一个.htaccess文件,定义一下规则即可,.htaccess文件的具体内容如下:

   1:  # Customized error messages.
   2:  ErrorDocument 404 /index.php
   3:   
   4:  # Set the default handler.
   5:  DirectoryIndex index.php
   6:   
   7:  # Various rewrite rules.
   8:  <IfModule mod_rewrite.c>
   9:    RewriteEngine on
  10:    RewriteCond %{REQUEST_FILENAME} !-f
  11:    RewriteCond %{REQUEST_FILENAME} !-d
  12:    RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
  13:  </IfModule>

在nginx下还需要再修改一下这个重定向。等我再研究。

posted @ 2013-03-29 10:43  HuangJacky  阅读(884)  评论(0编辑  收藏  举报
AdminLogin