首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >代码点火器3: 404页错误,.htaccess不工作

代码点火器3: 404页错误,.htaccess不工作
EN

Stack Overflow用户
提问于 2015-08-07 18:59:53
回答 2查看 943关注 0票数 0

它可能会对Codeigniter + 404页错误进行老的常规查询。我试着回答了以前关于这方面的堆叠溢出问题。但是我解决不了我的问题。

我已经将Codeigniter项目从另一个系统( Ubuntus 64位)复制到了Ubuntus OS系统。但是,作为default.If,我得到了404个页面--我给了http://localhost/project/index.php/admin/login它的工作,而不是http://localhost/project/admin/loginhttp://localhost/project

以下是我的配置:config.php

代码语言:javascript
复制
    $config['base_url'] = 'http://localhost/html/project';

    $config['modules_locations'] = array(
        APPPATH.'modules/' => '../modules/',
    );
    $config['index_page'] = '';
    $config['uri_protocol'] = 'AUTO'; 

还有我的.htaccess文件:

代码语言:javascript
复制
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> 
EN

回答 2

Stack Overflow用户

发布于 2015-08-07 19:13:57

检查是否启动了国防部重写。如果您使用的是apache2:

代码语言:javascript
复制
sudo a2enmod rewrite

然后重启apache。

代码语言:javascript
复制
sudo service apache2 restart
票数 1
EN

Stack Overflow用户

发布于 2015-08-07 19:03:46

尝试像这样重写它:

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31884859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档