Site_url在codeigniter中给出了错误的地址

时间:2016-06-25 11:32:50

标签: php codeigniter

我已经提供了以下base_url

$config['base_url'] = 'http://localhost/project/';

我有以下index.php:

$config['index_page'] = 'index.php';

现在按照配置文件中的两个条目,site_url应该是:

http://localhost/project/index.php

我目前在显示问题的页面http://localhost/project/index.php/question/get?id=2上。现在使用表单我正在添加问题:

    <form method="POST" action="<?php site_url(); ?>answer/post_answer" id="post_answer">

但是我的行动属性是:

http://localhost/project/index.php/question/answer/post_answer

不应该是:

http://localhost/project/index.php/answer/post_answer

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:2)

使用echo来使用site_url()

<form method="POST" action="<?php echo site_url(); ?>answer/post_answer" id="post_answer">