2012-04-24 74 views
0

,如果我不使用我不能笨2.1.0路由困难

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

负载控制器,但“?”并尝试从视图加载控制器,然后重复URL生成。 作为以上实例,如果我在视图形式操作添加该链接然后导致URL将被

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

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

+0

你有你的base_url()在config.php中设置? – 2012-04-24 21:29:05

+0

是的,它做到了。它应该是http:// localhost/codeigniter_folder_name的权利? – shantanu 2012-04-25 08:39:10

+0

确实http://localhost/index.php/controller/method工作? – 2012-04-25 10:19:00

回答

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'); ?> 

这将确保你的 “基本URL”,即http://localhost正确前置到要查看,即http://localhost/index.php/controller/method或者如果URL您已将其设置为,http://localhost/controller/method

加文