【问题标题】:Codeigniter routes.php Controllers are not working with lowercaseCodeigniter routes.php 控制器不能使用小写字母
【发布时间】:2019-03-28 13:40:32
【问题描述】:

我在.htaccess 中将我的控制器重定向为小写字母,但在重定向为小写字母后出现如下所示的错误。

我的Controllers文件名是:Seo_Services.php

我的 routes.php 文件声明是:

    $route['seo-services'] = 'Seo_Services';

注意:这适用于本地主机。不在 Godaddy 托管面板上工作。

请帮忙!

已编辑: 注意:为了更清楚,我只希望我的 url 是小写的。

工作: https://immacbytes.com/Seo-Services

不工作: https://immacbytes.com/seo-services

【问题讨论】:

    标签: php codeigniter routes


    【解决方案1】:

    Codeigniter 控制器示例和命名约定

    <?php
    class Blog extends CI_Controller {
    
            public function index()
            {
                    echo 'Hello World!';
            }
    }
    

    该文件必须名为“Blog.php”,大写“B”。

    类名必须以大写字母开头。

    这是有效的:

    <?php
    class Blog extends CI_Controller {
    
    }
    

    这是无效的:

    <?php
    class blog extends CI_Controller {
    
    }
    

    请检查并恢复。

    【讨论】:

    • 对不起 Bimal Kumar,我想你还没有理解我的问题。我知道控制器必须以大写字母开头。一切正常,我只希望我的网址从 immacbytes.com/Seo-Servicesimmacbytes.com/seo-services
    • 我的网址适用于 Seo-Services。但我想将其降低到 .i.e seo-services。
    【解决方案2】:

    我只知道我的web.config 是错误的。我正在通过一条规则,将 Seo-Services 重定向到 seo-services。规则如下:

    <rule name="bfgfgg-fgfg-g-ff" stopProcessing="true">
        <match url="Seo-Services" />
        <action type="Redirect" url="seo-services" />
    </rule>
    

    可能是web.config 规则不区分大小写。所以这条规则被一次又一次地触发。结果我得到了错误。

    谢谢!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-28
      • 2015-11-28
      • 2016-08-15
      • 1970-01-01
      • 2012-11-20
      • 2016-11-09
      相关资源
      最近更新 更多