CodeIgniter 中的 URI 路由

发布于 2024-11-15 03:43:57 字数 164 浏览 2 评论 0原文

此链接有效 site.tv/admin/edit/ (controllers/admin/edit.php),但此链接无效 site.tv/admin/reg/edit/ (controllers/ admin/reg/edit.php) 控制器的路径是否太长?

This link works site.tv/admin/edit/ (controllers/admin/edit.php), but this doesn't work site.tv/admin/reg/edit/ (controllers/admin/reg/edit.php) Is it too long path to controller?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

诺曦 2024-11-22 03:43:57

你的路由应该是index.php/CLASS/METHOD/ID

引用自application/config/routes.php

通常,URL 字符串之间存在一对一的关系
及其相应的控制器类/方法。 a 中的段
URL 通常遵循以下模式:

example.com/class/method/id/

例如

class test extends CI_Controller{

    public function hello() {
        echo 'hello world';
    }

    public function meep() {
        echo 'meeeeeep';
    }

    public function param($value){
            echo 'Your parameter is '. $value;
    }
}

那么你的 url 应该是 index.php/test/hello, index.php/test/meep 和 index.php/test/param/whataeverhere

更新

如果您需要“多个包”,请为“包”创建子目录

controllers
    ->admin
           ->reg
                ->myfile.php
                ->myfile2.php
           ->reg2
                ->myfile.php
                ->myfile2.php

,然后创建自定义路由在application/config/ 文件夹下的 routes.php

Your routing should be index.php/CLASS/METHOD/ID

Quote from application/config/routes.php

Typically there is a one-to-one relationship between a URL string
and its corresponding controller class/method. The segments in a
URL normally follow this pattern:

example.com/class/method/id/

for example

class test extends CI_Controller{

    public function hello() {
        echo 'hello world';
    }

    public function meep() {
        echo 'meeeeeep';
    }

    public function param($value){
            echo 'Your parameter is '. $value;
    }
}

Then your url should be index.php/test/hello, index.php/test/meep and index.php/test/param/whataeverhere

UPDATE:

If you need "multiple packages" create subdirectories for your "packages" like in

controllers
    ->admin
           ->reg
                ->myfile.php
                ->myfile2.php
           ->reg2
                ->myfile.php
                ->myfile2.php

and then create your custom routes in routes.php under application/config/ folder

永不分离 2024-11-22 03:43:57

我认为这是 CHMOD 的问题。
检查 reg fils 是否可读。

I think it's a problem to CHMOD.
check if reg fils it's readeable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文