现有控制器上的codeigniter 404

Sin*_*uja 2 codeigniter

我在codeigniter中遇到了一个不同的问题.

当我尝试访问我网站中的视频页面时,它将重定向到404.shtml页面.但是cvideos.php文件存在于我的控制器文件夹中.

如果我像这样访问http://域名/视频,那么它将被重定向到这样//domain-name/500.shtml

如果我像这样访问同一页面//域名/视频/ myvideos,那么它将被重定向到这样//domain-name/404.shtml

此外,如果我将控制器名称从视频更改为其他名称,如视频,它可以正常工作.任何人都可以告诉wats这个问题.

我在.htaccess中使用这一行也只是为了测试.但没用.

RewriteRule ^ videos/$ index.php/videoss/[L]

Ros*_*oss 5

您的控制器需要与其包含的类名称相同.

因此 -

<?php

controller Videos extends Controller {

 /* bla */
}

?>
Run Code Online (Sandbox Code Playgroud)

应保存为:

videos.php 在"controllers"目录中.

没有别的办法.

你的重写规则也有两个"s",但这可能是故意的.

看起来你正在尝试用.htaccess可以通过CI的路由来实现


编辑:.htaccess

<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>  
Run Code Online (Sandbox Code Playgroud)

请注意我没有创建这个 - 它是通过搜索CI论坛找到的.然而,这是一个相当彻底的htaccess.

不要忘记在配置中将"index.php"的值设置为"".