现有控制器上的 codeigniter 404

2024-01-17

我在 codeigniter 中面临不同的问题。

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

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

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

另外,如果我将控制器名称从视频更改为其他名称(例如视频),它可以正常工作。任何人都可以告诉问题是什么。

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

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


您的控制器需要与其包含的类同名。

hence -

<?php

controller Videos extends Controller {

 /* bla */
}

?>

应另存为:

videos.php在“控制器”目录中。

其他的都行不通。

您的重写规则也有两个“s”,但这可能是故意的。

看起来你想用 .htaccess 做的事情可以通过 CI 来实现routing http://codeigniter.com/user_guide/general/routing.html


编辑:.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>  

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

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

现有控制器上的 codeigniter 404 的相关文章

随机推荐