从DirectAdmin上的codeigniter安装的url中删除index.php

时间:2014-01-09 03:04:24

标签: apache .htaccess codeigniter mod-rewrite

我正在尝试在我的codeigniter安装上使用.htaccess从URL中删除index.php,我正在使用mod_rewrite。

但是,它不起作用,我已将.htaccess文件放在我的codeigniter安装文件夹(应用程序和系统文件夹所在的位置)的根目录中。 DirectAdmin 1.44.3(在Apache 2.2.26上)。

我的.htaccess文件如下:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|img|css|js|robots\.txt)
RewriteCond $1 !^(index\.php|application/views/|robots\.txt|install|favicon\.ico|documents)
RewriteRule ^(.+)$ index.php?$1 [L]
RewriteBase /
DirectoryIndex index.php


#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]

 </IfModule>
 <IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
     # Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule> 

我应该如何删除DirectAdmin上的index.php?

2 个答案:

答案 0 :(得分:0)

**Try This:**
Remove index.php from application/config/config.php then save it.
$config['index_page'] = 'index.php';

答案 1 :(得分:0)

更改 config.php

$config['index_page'] = 'index.php';

$config['index_page'] = '';

然后使用以下 .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>