尝试删除codeigniter中的index.php

时间:2013-02-01 05:11:43

标签: php codeigniter

  

可能重复:
  How to remove “index.php” in codeigniter’s path

1.使用以下代码

在codeigniter目录中创建.htaccess文件
 <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteBase /ex/
     RewriteCond $1 ^(application|system|private|logs)
     RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
     RewriteCond $1 ^(index\.php|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)
     RewriteRule ^(.*)$ - [PT,L]
     RewriteRule ^(.*)$ index.php/$1 [PT,L]
  </IfModule>

2.将config['index_page']='index.php'更改为config['index_page']=''

但它不起作用。我的httpd.conf(/ etc / apache2 /)是空白的

3 个答案:

答案 0 :(得分:1)

确保您已在Apache模块上启用 rewrite_module

RewriteEngine On
RewriteBase /ex/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

答案 1 :(得分:0)

在.htaccess文件中尝试此操作

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

答案 2 :(得分:0)

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]