douzhuo8871 2014-04-16 19:57
浏览 51
已采纳

Base_url()是否在我的网址中添加了不必要的细分?

My base_url() is adding more bits into the url than it should be. What is wrong with my setup? I have the helper set up in config.php:

$autoload['helper'] = array('url');

My base_url() is set to: index.php/

So the problem is that when I activate this form:

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

The first time I access it, I'll type in: localhost/CIintranet/ and the the base_url() gets added next so it becomes: localhost/CIintranet/index.php/

I'm trying to program a login logout system though. So if the user login is incorrect, I want it to redirect back to the login page. Here's the code from the controller for that part:

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>";
        }
    }

But when it reloads the login_form, it adds another part into the url and the url fails. So the progression is like this:

Page loads to this url:

localhost/CIintranet/

First failed attempt (page still loads properly):

localhost/CIintranet/index.php/welcome/login_submit

Second failed attempt (page fails to load):

localhost/CIintranet/index.php/welcome/index.php/welcome/login_submit 

I've been doing some research on this for a bit now and I'm noting a lot of people talking about the htaccess file in relation to this problem but nobody seems to mention specifically what fixes it or how to configure the base_url() so that it just takes care of this properly. I tried looking at the documentation but perhaps I missed something. I didn't find what I was looking for.

Any ideas?

  • 写回答

2条回答 默认 最新

  • doulun1915 2014-04-17 02:02
    关注

    Can you try setting the base_url to /index.php/? So it has the forward slash at the front too?

    Failing that, please try: http://localhost/CIintranet/index.php/

    It's usually the simple things!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度