Codeigniter 代码点火器:尾部斜线
在我的CI应用程序中,我有以下控制器:Codeigniter 代码点火器:尾部斜线,codeigniter,codeigniter-url,php,Codeigniter,Codeigniter Url,Php,在我的CI应用程序中,我有以下控制器: http://localhost/myapp/index.php/frontend/login/ 在这个控制器(登录控制器)中,我有一个名为submit()的方法。此控制器的关联视图文件有一个带有action='submit/'的表单。这个想法是当表单提交时,它会转到http://localhost/myapp/index.php/frontend/login/——只要URL后面有斜杠,它就会这样做 但是,如果URL如下所示(无尾随斜杠): 当我提交表格
http://localhost/myapp/index.php/frontend/login/
在这个控制器(登录控制器)中,我有一个名为submit()
的方法。此控制器的关联视图文件有一个带有action='submit/'
的表单。这个想法是当表单提交时,它会转到http://localhost/myapp/index.php/frontend/login/
——只要URL后面有斜杠,它就会这样做
但是,如果URL如下所示(无尾随斜杠):
当我提交表格时,我被重定向到以下位置:
http://localhost/myapp/index.php/frontend/submit/
由于我没有
submit
控制器,因此导致404。您是否使用CI的表单帮助程序
//autoload/controller:
$this->load->helper('form');
// in your view:
<?php echo form_open('login/submit'); ?>
在操作中使用绝对URL
action="/myapp/index.php/frontend/submit/"
1.)不,我没有使用CI form helper,2。)“frontend”只是控制器目录中的一个文件夹。知道哪里不对吗?有没有办法让表单帮助器添加尾随斜杠?
controllers/
|-frontend
|-front_end_controller.php
action="/myapp/index.php/frontend/submit/"