codeigniter 2.1.0路由困难

时间:2012-04-24 21:27:11

标签: codeigniter-2

我无法使用

加载控制器
http://localhost/index.php?controller/method

但如果我不使用'?'并尝试从视图加载控制器然后重复URL生成。 作为上述示例,如果我在视图中的表单操作中添加此链接,则结果URL将为

http://localhost/index.php/controller/index.php/controller/method

如何解决?我没有使用htaccess文件

1 个答案:

答案 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

加文