为了账号安全,请及时绑定邮箱和手机立即绑定

redirect() 将整个 URL 添加到根目录

redirect() 将整个 URL 添加到根目录

PHP
翻翻过去那场雪 2021-08-27 09:45:56
当我使用 header('Location: index') 时,我得到“localhost/pos/index”,当我使用 redirect('index') 时,我得到“localhost/pos/localhost/pos/index”。我在 Windows 10 上使用 XAMPP。“localhost/pos”是我的应用程序的根。我尝试使用“刷新”和“位置”无济于事。我尝试将控制器添加到 URI(因此使用 redirect('main/index') 代替),我在 URI 的开头尝试了一个斜杠 - 每次,redirect() 都以我之前指出的这种奇怪的方式工作。当我尝试从 redirect() 主体复制 header() 代码时,它实际上按预期工作...redirect('index'); // Does the weird repeated URLheader('Location: index'); // Works fineheader('Location: '.$uri, TRUE, $code); // Works fine, even though it's redirect()'s body when $metod == 'location'重定向('索引'):预期:http://localhost/pos/index结果:http://localhost/pos/localhost/pos/index
查看完整描述

1 回答

?
慕码人2483693

TA贡献1860条经验 获得超9个赞

设置你的base_urlin config.php,我猜你的项目名称pos应该是这样的:

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


查看完整回答
反对 回复 2021-08-27
  • 1 回答
  • 0 关注
  • 282 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信