Php 编码点火器->;获取404错误。简单路线不起作用

Php 编码点火器->;获取404错误。简单路线不起作用,php,codeigniter,Php,Codeigniter,我是一个asp.net的家伙,这是我第一次处理PHP 无论如何,我一直在努力将现有站点迁移到新服务器 此站点正在使用codeigniter 当我打电话时 我得到一个404错误 但如果我打电话: 它起作用了 我已在根目录下放置了一个.htaccess文件: RewriteEngine on RewriteCond $1 !^(index\.php|images|stylesheets|scripts|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L

我是一个asp.net的家伙,这是我第一次处理PHP

无论如何,我一直在努力将现有站点迁移到新服务器

此站点正在使用codeigniter

当我打电话时 我得到一个404错误

但如果我打电话:

它起作用了

我已在根目录下放置了一个.htaccess文件:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|stylesheets|scripts|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
我在config.php中设置了:

$config['index_page'] = '';
My routes.php:

$route['default_controller'] = 'welcome';
$route['scaffolding_trigger'] = '';
我不知道为什么它不起作用。我想这一定很简单


谢谢大家!

你看过了吗

如果没有,请尝试以下方法:

<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
    #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> 

重新启动发动机
重写基/
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$/index.php?/$1[L]
#当应用程序文件夹不在系统文件夹中时
#此代码段阻止用户访问应用程序文件夹
#提交人:Fabdrol
#将“应用程序”重命名为应用程序文件夹名称。
重写cond%{REQUEST_URI}^应用程序*
重写规则^(.*)$/index.php?/$1[L]
#检查用户是否试图访问有效文件,
#例如图像或css文档,如果这不是真的,它会发送
#请求index.php
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php

我曾经用过杰米·鲁姆的一本,但现在已经不在他的博客上了。。。不过,我现在已经习惯使用nginx,所以我最喜欢的配置对您不起作用。

尝试在.htaccess中添加
RewriteBase/

尝试以下操作:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]

你的.htaccess文件对我也不起作用。但一旦我将重写规则更改为:

RewriteRule ^(.*)$ index.php/$1 [L]

我刚删除了开头的斜杠。

-在您的CodeIgniter项目根目录中创建一个.htaccess文件

-在创建的.htaccess文件中输入代码:


你得到的是CI 404还是服务器的404?我怎么知道是CI的错误还是服务器的错误?它似乎是Apache,因为我看不出它有什么特别之处。这里是链接:也许你可以告诉我哪里出了问题。这个有效:谢谢!!!!等待链接现在起作用了。这是不是意味着你已经修好了?…而且没有报告?真丢脸!;-)Matthew,我刚刚用您粘贴的内容替换了.htaccess的内容,现在我得到:500内部服务器错误请求未完成。服务器遇到意外情况。调用页面时。有没有办法知道是否启用了mod_rewrite?我猜htaccess的最后一部分说,如果模块不存在,那么执行404-尽管不确定。在大多数情况下(以我的经验),它似乎不是默认启用的,而是安装的。我用了记事本,现在500错误消失了,但我又犯了404错误。不幸的是,它没有帮助。您应该真正查看apache日志,以获取关于发生了什么的提示。在htaccess中,一切似乎都很好
            $default_controller = "home";
            $language_alias = array('gr','fr');
            $controller_exceptions = array('signup');
            $route['default_controller'] = $default_controller;
            $route["^(".implode('|', $language_alias).")/(".implode('|', $controller_exceptions).")(.*)"] = '$2';
            $route["^(".implode('|', $language_alias).")?/(.*)"] = $default_controller.'/$2';
            $route["^((?!\b".implode('\b|\b', $controller_exceptions)."\b).*)$"] = $default_controller.'/$1';
            foreach($language_alias as $language)
            $route[$language] = $default_controller.'/index';
            $route['404_override'] = '';