Codeigniter 3删除index.php问题

Codeigniter 3删除index.php问题,php,apache,.htaccess,codeigniter,mod-rewrite,Php,Apache,.htaccess,Codeigniter,Mod Rewrite,我有一个在codeigniter 2.1.4中为客户开发的小项目,现在,他坚持要迁移到codeigniter 3开发版本。我知道这不是个好主意但是。。。 我的问题是无法从url中删除index.php 这是我的.htaccess文件: Options +FollowSymLinks RewriteEngine on # Send request via index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{R

我有一个在codeigniter 2.1.4中为客户开发的小项目,现在,他坚持要迁移到codeigniter 3开发版本。我知道这不是个好主意但是。。。 我的问题是无法从url中删除index.php

这是我的.htaccess文件:

  Options +FollowSymLinks
  RewriteEngine on

  # Send request via index.php
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
我已经从config.php文件中删除了index.php
运气不好
我重新安装了LAMP服务器(我在Ubuntu 12.04上),重新配置了
我在本地服务器上有其他项目是在Codeigniter 2.1.4和Laravel 4上开发的,它们工作得很好,但这一个让我很痛苦。

谢谢

如果您的Apache服务器启用了mod_rewrite,您可以使用带有一些简单规则的.htaccess文件轻松删除此文件

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

删除index.php之后的
我已经再次克隆了git存储库,并对lamp进行了干净的安装,现在它可以工作了。

请将以下代码添加到.htaccess文件中,并将其直接包含到/codeigniter\u项目\u文件夹中

重新启动发动机 重写cond%{REQUEST_FILENAME}-F 重写cond%{REQUEST_FILENAME}-D 重写规则。*index.php/$0[PT,L]
在CI项目的根目录上创建新的.htaccess文件,并在其中添加代码。不要更改应用程序文件夹中的.htaccess文件。这对我来说很有用

只需下载CI版本
2.2.0

从根目录复制
.htaccess
htaccess.txt
,并将其粘贴到Codeigniter 3项目中

不要忘记更改
.htaccess
文件中的项目名称。

我这样做:

在项目的根文件夹中创建了.htaccess,内容如下:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|css|js|images|robots\.txt)
RewriteRule ^(.*)$ index.php?$1 [L]
然后,在config.php中,我修改了这一行

发件人:

致:

  • 在www/project\u文件夹或htdocs/project\u文件夹中创建新的htaccess文件

  • 使用
    echo phpinfo()

  • 只需粘贴以下代码即可工作:

    <IfModule mod_rewrite.c>
    
        RewriteEngine on
        RewriteCond $1 !^(index\.php|images|robots\.txt)
        RewriteRule ^(.*)$ /project_folder/index.php/$1 [L]  
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        ErrorDocument 404 /index.php
    </IfModule>
    
    
    重新启动发动机
    1美元^(索引\.php | images | robots\.txt)
    重写规则^(.*)$/project_folder/index.php/$1[L]
    ErrorDocument 404/index.php
    
  • 将项目文件夹更改为您自己的文件夹


  • 在.htaccess文件中添加以下行

    RewriteCond %{REQUEST_URI} ^/system.*
    RewriteRule ^(.*)$ index.php?/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ index.php?/$1 [L]
    
    还可以编辑应用程序/config/config.php文件。与

    $config[‘index_page’] = “”;
    $config[‘uri_protocol’] = “AUTO“;
    
    它会起作用的

  • 在项目根文件夹中创建一个
    .htacess
    文件
    /your\u codeigniter\u project\u文件夹/.htacess
    ,然后粘贴此代码

    重新启动发动机

    重写cond%{REQUEST_FILENAME}-f

    重写cond%{REQUEST_FILENAME}-d

    重写规则^(.*)$index.php/$1[L]

  • 在config.php文件
    $config['base\u URL']='http://yourhost/CI_project_folder/';

  • 设置URL后缀
    $config['URL_suffix']='.php'
  • *如果不起作用,请检查此项*

  • 确保在
    .htacess
    所在的根文件夹中没有任何与控制器名称相同的文件。 示例:您有一个
    users.php
    控制器,并且在
    /Your\u codeigniter\u project\u文件夹/users.php
    如果有,请将其删除
    /Your\u codeigniter\u project\u文件夹/users.php

  • 确保服务器处于“重写”模式(从此行开头删除)

    LoadModule rewrite_module modules/mod_rewrite.so


  • 注意项目路径的大写字母。
    i、 e.如果基本url为
    http://localhost/ci/
    而目录名是
    CI
    ,它可能不起作用。

    只是出于好奇:你的客户端怎么能区分版本2和版本3,但却无法转换自己?@php\u nub\u qq ya,不管怎样,我读到的是CI3的全部内容:@他不可能,但有人把这个东西塞进了他的脑袋。以下是一些资源,它们实际上没有问号地展示了代码。看看是否有这些帮助我已经尝试过这个选项。。。
    <IfModule mod_rewrite.c>
    
        RewriteEngine on
        RewriteCond $1 !^(index\.php|images|robots\.txt)
        RewriteRule ^(.*)$ /project_folder/index.php/$1 [L]  
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        ErrorDocument 404 /index.php
    </IfModule>
    
    RewriteCond %{REQUEST_URI} ^/system.*
    RewriteRule ^(.*)$ index.php?/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ index.php?/$1 [L]
    
    $config[‘index_page’] = “”;
    $config[‘uri_protocol’] = “AUTO“;