【问题标题】:redirect() adds the whole URL to the rootredirect() 将整个 URL 添加到根
【发布时间】:2019-06-17 17:37:07
【问题描述】:

当我使用 header('Location: index') 时,我得到“localhost/pos/index”,当我使用 redirect('index') 时,我得到“localhost/pos/localhost/pos/index”。我在使用 XAMPP 的 Windows 10 上。 “localhost/pos”是我的应用程序的根目录。

我尝试使用“刷新”和“位置”无济于事。我尝试将控制器添加到 URI(所以改为使用 redirect('main/index')),我尝试在 URI 的开头使用斜杠 - 每次,redirect() 都以我之前指出的这种奇怪方式工作。当我尝试从 redirect() 主体复制 header() 代码时,它实际上按预期工作......

redirect('index'); // Does the weird repeated URL
header('Location: index'); // Works fine
header('Location: '.$uri, TRUE, $code); // Works fine, even though it's redirect()'s body when $metod == 'location'

重定向('索引'):

【问题讨论】:

    标签: php codeigniter codeigniter-3


    【解决方案1】:

    config.php 中设置你的base_url,我猜你的项目名称是pos 那么它应该是这样的:

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

    【讨论】:

    • 惊喜惊喜 - 我将我的基本网址设置为“localhost/pos”。您需要在开头使用“http://”。谢谢!
    猜你喜欢
    • 2018-12-09
    • 2020-08-02
    • 1970-01-01
    • 2015-10-31
    • 2020-08-16
    • 1970-01-01
    • 2017-10-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多