使用 URL 路由在 CodeIgniter 中创建子页面

Creating a sub-page in CodeIgniter using URL routing

我的表格开始变得有点太复杂了,所以我想将一页分成三个不同的页面。我知道我需要使用 URL 路由来实现这一点,但到目前为止还没有运气。阅读手册没有帮助。

当前URL如下:

index.php/profiles/edit/$id

我想实现这样的目标:

index.php/profiles/edit/contact/$id
index.php/profiles/edit/pictures/$id
...

您不需要做路由。您可以像这样简单地改进您的编辑功能。

public function edit($type,$id)
{
    if($type=='contact')
    {
        //do contact task
    }
    if($type=='pictures')
    {
        //do picture task
    }

}

现在您预期的链接将起作用。