CodeIgniter Forums
URL bug - A segment of '0' returns false? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: URL bug - A segment of '0' returns false? (/thread-58377.html)



URL bug - A segment of '0' returns false? - El Forum - 06-07-2013

[eluser]Rokkitt[/eluser]
Seriously. This is causing me all kind of headaches. Have the same code locally as I do on my server. Both are running PHP 5.4.

config/routes.php

Code:
$route['default_controller'] = "frontend/run";
$route['send_contact/(:num)'] = "frontend/send_contact/$1";
$route['404_override'] = 'frontend/run';

controllers/frontend.php > run()

Code:
public function run()
{
// Get Page
var_dump($this->uri->segment(1)); exit;
}

Tests

mysite.com/blah
// Returns: string(4) "blah"

mysite.com/1
// Returns: string(1) "1"

On my server.. broken..

mysite.com/0
// Returns: bool(false)

Locally.. works..

mysite.com/0
// Returns: string(0) "0"

Can anyone else recreate this? Any idea why this is happening?


URL bug - A segment of '0' returns false? - El Forum - 06-07-2013

[eluser]Rokkitt[/eluser]
Been plugging away at this for 2 hours.. surprising what posting can shake loose.

Server required the following config setting.

<code>$config['uri_protocol'] = 'REQUEST_URI';</code>

I don't know if this would be classed as a CI error. Rather annoying though. Use a URI of 0 to check that the uri_protocol is properly configured I guess.