VlT*_*lTr 2 php routing uri codeigniter
此链接有效site.tv/admin/edit/ (controllers/admin/edit.php),但这不起作用site.tv/admin/reg/edit/ (controllers/admin/reg/edit.php) 是否是控制器的路径太长?
您的路由应该是index.php/CLASS/METHOD/ID
从application/config/routes.php引用
通常,URL字符串与其对应的控制器类/方法之间存在一对一的关系.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;
}
}
Run Code Online (Sandbox Code Playgroud)
然后你的网址应该是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
Run Code Online (Sandbox Code Playgroud)
然后在routes.php下面的application/config/文件夹中创建自定义路由