Codeigniter 3: 404页面错误,.htaccess不工作


Codeigniter 3 : 404 page error, .htaccess not working

可能是Codeigniter + 404页面错误的老查询。我已经尝试从以前的stackoverflow问题回答了这个问题。但是,我不能解决我的问题。
我已经将Codeigniter项目从另一个系统(Ubuntu OS 64位)复制到Ubuntu OS系统。但是,我得到404页面作为默认值。如果我让http://localhost/project/index.php/admin/login工作,而不是http://localhost/project/admin/loginhttp://localhost/project
以下是我的配置: config。

    $config['base_url'] = 'http://localhost/html/project';
    $config['modules_locations'] = array(
        APPPATH.'modules/' => '../modules/',
    );
    $config['index_page'] = '';
    $config['uri_protocol'] = 'AUTO'; 

。htaccess file:

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

检查mod重写是否开启。如果您正在使用apache2:

sudo a2enmod rewrite

然后重新启动apache。

sudo service apache2 restart

试着这样重写:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    #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
    #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.
    ErrorDocument 404 /index.php
</IfModule>