【问题标题】:removing index.php from url of codeigniter installation on DirectAdmin从 DirectAdmin 上的 codeigniter 安装的 url 中删除 index.php
【发布时间】:2014-01-27 10:55:30
【问题描述】:

我正在尝试在我的 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?

【问题讨论】:

    标签: apache .htaccess codeigniter mod-rewrite


    【解决方案1】:

    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>
    

    【讨论】:

      【解决方案2】:
      **Try This:**
      Remove index.php from application/config/config.php then save it.
      $config['index_page'] = 'index.php';
      

      【讨论】:

        猜你喜欢
        • 2016-01-11
        • 1970-01-01
        • 2016-05-14
        • 2014-10-28
        • 2012-06-15
        • 2012-09-21
        • 2011-10-12
        相关资源
        最近更新 更多