【发布时间】:2014-05-31 21:19:10
【问题描述】:
我的 base_url() 在 url 中添加了比应有的更多位。我的设置有什么问题?我在 config.php 中设置了助手:
$autoload['helper'] = array('url');
我的 base_url() 设置为:index.php/
所以问题是当我激活这个表单时:
<h1>sometimes haikus don't make sense refrigerator</h1>
<form action="<?php echo base_url(); ?>welcome/login_submit" method="post">
<label>
email:
<input id="email" name="email" />
</label>
<label>
password:
<input type="password" id="password" name="password" />
</label>
<input type="submit" value="Log me in!" />
</form>
我第一次访问它时,我会输入:localhost/CIintranet/,接下来会添加 base_url(),所以它变成:localhost/CIintranet/index.php/
我正在尝试编写一个登录注销系统。因此,如果用户登录不正确,我希望它重定向回登录页面。这是该部分控制器的代码:
public function login_submit() {
$this->load->model('LoginChecker', 'users');
//$this->load->view('login_submit');
$match = $this->users->authenticate_user( $_POST['email'], $_POST['password'] );
if( $match )
{
$this->load->view('login_submit');
echo "User exists in database!";
}
else
{
$this->load->view('login_form');
echo "<h1>Email or password is wrong, bretheren!</h1>";
}
}
但是当它重新加载 login_form 时,它会在 url 中添加另一部分并且 url 失败。所以进度是这样的:
页面加载到这个网址:
localhost/CIintranet/
第一次尝试失败(页面仍然正常加载):
localhost/CIintranet/index.php/welcome/login_submit
第二次尝试失败(页面加载失败):
localhost/CIintranet/index.php/welcome/index.php/welcome/login_submit
我已经对此进行了一些研究,我注意到很多人都在谈论与此问题相关的 htaccess 文件,但似乎没有人具体提及修复它的方法或如何配置 @ 987654327@ 以便它妥善处理此问题。我尝试查看文档,但也许我错过了一些东西。我没有找到我要找的东西。
有什么想法吗?
【问题讨论】:
-
config.php中$config['base_url']的值是多少?
标签: php .htaccess codeigniter login base-url