CodeIgniter Forums
URI segments null - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: URI segments null (/showthread.php?tid=15710)



URI segments null - El Forum - 02-12-2009

[eluser]mscahill[/eluser]
I'm developing on Linux, and have a stable application. Now, when testing on Windows, all of my $this->uri->segment() calls are null. For example, when I visit
Code:
http://localhost/first_run
I get NULL when I access
Code:
$this->uri->segment(1)
. Is this a portability problem? Is there a work-around? Can the problem be related to header('Location: ') calls?


URI segments null - El Forum - 02-12-2009

[eluser]TheFuzzy0ne[/eluser]
Have you run through the configuration again in the ./system/application/config/config.php and ./index.php? The problem may be that the site URL, or query protocol may be incorrect. Also, please confirm that your .htaccess file has been uploaded. By the looks of your URL, you have an .htaccess file, but some FTP clients ignore hidden files unless told not to.


URI segments null - El Forum - 02-12-2009

[eluser]mscahill[/eluser]
Code:
$config['base_url']    = "http://localhost/";
$config['uri_protocol']    = "AUTO";

.htaccess exists, and is redirecting properly


URI segments null - El Forum - 02-12-2009

[eluser]mscahill[/eluser]
I'm convinced that it's still reading the REQUEST_URI of / even though I'm using header to forward to /first_run. This might be more apache/php under windows kind of thing. Wouldn't the REQUEST_URI change after a header('Location: ') call?


URI segments null - El Forum - 02-12-2009

[eluser]TheFuzzy0ne[/eluser]
It's probably a problem with the URI protocol. I would try each one in the list first, and see if your results change at all.


URI segments null - El Forum - 02-12-2009

[eluser]mscahill[/eluser]
meaning?


URI segments null - El Forum - 02-12-2009

[eluser]TheFuzzy0ne[/eluser]
In your config.php file, there's a list of possible URI protocols for CodeIgniter to use. By default, it's set to AUTO, which doesn't always work. I would suggest trying each of the other options and seeing if a manual override works.


URI segments null - El Forum - 02-12-2009

[eluser]mscahill[/eluser]
Just a heads up, I placed this line of code in the first file that loads in my appliation:
Code:
die($CI->uri->segment(1, 'no segment'));

On my Windows box:
Visiting / returns 'no segment'
Visiting /first_run returns 'no segment'

On my Linux box:
Visiting / returns 'no segment'
Visiting /first_run return 'first_run'


URI segments null - El Forum - 02-12-2009

[eluser]mscahill[/eluser]
Switching to REQUEST_URI fixed the problem. Thanks.