【问题标题】:Codeigniter redirect doubles URLCodeigniter 重定向双打 URL
【发布时间】:2014-03-11 04:52:57
【问题描述】:

我在 localhost 中使用 codeigniter,我试图将我的控制器重定向到另一个控制器,所以我基本上做的是:

        redirect('/account/index');

但是,它不会转到 URL,而是转到此处:

http://localhost/ticketsystem/index.php/logincheck/localhost/ticketsystem/index.php/account/index

它使我的地址翻倍。我需要在我的 config.php 中设置一些东西吗?我在 config.php 中的设置是

$config['base_url'] = 'localhost/ticketsystem';

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

$config['uri_protocol'] = 'AUTO';

我是否需要在那里更改某些内容,或者我是否正在做其他事情导致我的重定向出现问题?

【问题讨论】:

    标签: php codeigniter redirect controller


    【解决方案1】:

    base_url 行为类似于相对路径,更改为完整的 url,并在最后添加 '/'

    $config['base_url'] = 'localhost/ticketsystem';
    

    到

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

    【讨论】:

      【解决方案2】:

      你的基本网址应该是这样的

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

      使用重定向,例如:-

      redirect('account/index', 'refresh');
      

      刷新将使用元刷新并应该快速重定向

      【讨论】:

        【解决方案3】:

        尝试删除帐户前的“/”!

        redirect('account/index');
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-11-12
          • 2013-04-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-09-16
          相关资源
          最近更新 更多