我无法使用
加载控制器http://localhost/index.php?controller/method
但如果我不使用'?'并尝试从视图加载控制器然后重复URL生成。 作为上述示例,如果我在视图中的表单操作中添加此链接,则结果URL将为
http://localhost/index.php/controller/index.php/controller/method
如何解决?我没有使用htaccess文件
答案 0 :(得分:0)
使用site_url()
函数,或者如@JohnFable所述,使用form_open
函数。
<form method="post" action="<?= form_open('controller/method'); ?>">
或
<a href="<?= site_url('controller/method'); ?>">Controller/Method</a>
或
<?= form_open('controller/method'); ?>
这将确保您的“基本网址”,即http://localhost
正确地预先添加到您要查看的网址,即http://localhost/index.php/controller/method
,或者如果您已将其设置为http://localhost/controller/method
加文