redirect() adds the whole URL to the root

Viewed 37

When I use header('Location: index') I get "localhost/pos/index", when I use redirect('index') I get "localhost/pos/localhost/pos/index" instead. I'm on Windows 10 using XAMPP. "localhost/pos" is the root of my application.

I tried using 'refresh' and 'location' to no avail. I tried adding the controller to the URI (so redirect('main/index') instead), I tried a slash at the beginning of the URI - every time, redirect() worked in this weird way I pointed out earlier. When I tried copying the header() code from redirect() body, it actually worked as it was supposed to...

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'

redirect('index'):

1 Answers

Set your base_url in config.php, i guess your project name is pos then it should look like this:

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