Part of the EllisLab Network
   
 
CI 1.6 >> Problem with URI library not picking up first segment
Posted: 26 January 2008 06:38 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  95
Joined  03-05-2006

I’ve had a good look round and no-one seems to have had this problem yet, so it could be something freaky at my end, but here goes.

I’ve got my CI 1.54 project set up so that the index.php is rewritten out, so…

/home

redirects to..

/index.php/home

...which is then routed internally to a controller in shop/home.

On upgrading to 1.6 I’m getting a 404 when issuing /home, although /index.php/home works. On inspection it seems that libraries/URI.php wasn’t quite picking up the first segment.

Here’s the original code from line 73 or so of URI.php, in the method _fetch_uri_string():

$key = array_keys($_GET);
$index = current($key);
$this->uri_string = $_GET[$index];                
return;

I changed the third line here to read:

$this->uri_string = $index;

... and now it works. I’m using the same htaccess for stripping out the index.php across both versions, by the way. Could someone verify this bug and fix?

BTW I’m using MAMP1.7 on a Macbook, and the issue occurred in both PHP4.47 and PHP 5.2.3.

Profile
 
 
Posted: 26 January 2008 07:07 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  737
Joined  10-18-2006

I have the same problem on Windows XP running PHP 4.3.9, 4.4.7, 5..0.0, 5.1.6 and 5.2.5. To test I just use a index.php?controller/method

 Signature 

Once in a while I remember I use Twitter

Profile
 
 
Posted: 26 January 2008 07:09 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  95
Joined  03-05-2006

Great, thanks Seppo. Did the suggested fix work?

Profile
 
 
Posted: 26 January 2008 07:13 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  737
Joined  10-18-2006

Yeap.
I suggest you to report it in the bug tracker

 Signature 

Once in a while I remember I use Twitter

Profile
 
 
Posted: 26 January 2008 07:14 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  95
Joined  03-05-2006

Cheers Seppo, will do.

Now logged as bug 3321

Profile
 
 
Posted: 26 January 2008 08:46 AM   [ Ignore ]   [ # 5 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
Joined  06-10-2007

Same issue with CI 1.6.0 here too (except I thought it was my routes setup). Thanks for this.

 Signature 

URI Language Identifier | Modular Extensions - PHP5 | Modular Separation - PHP5 | Widget plugin | Access Control library

Profile
 
 
Posted: 29 January 2008 06:30 PM   [ Ignore ]   [ # 6 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19292
Joined  06-03-2002

Steve, what is your .htaccess that you are using.  With that URL, I don’t even see how that code is being triggered for you, as you aren’t using query strings.

 Signature 
Profile
MSG
 
 
Posted: 30 January 2008 04:49 PM   [ Ignore ]   [ # 7 ]  
Grad Student
Avatar
Rank
Total Posts:  95
Joined  03-05-2006

Derek - the latest updates to SVN seem to have fixed it, thanks.

Profile
 
 
Posted: 30 January 2008 04:58 PM   [ Ignore ]   [ # 8 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19292
Joined  06-03-2002

Cool, yes, that bug was confirmed and fixed - but to satiate my curiosity, I’d still like to know how your URLs are being formed.  What you show in your original post would not set any GET data at all.

 Signature 
Profile
MSG
 
 
Posted: 30 January 2008 05:03 PM   [ Ignore ]   [ # 9 ]  
Grad Student
Avatar
Rank
Total Posts:  95
Joined  03-05-2006

...sorry, I left out the domain, just a local dev thing. I don’t own shop.co.uk…

http://dev.shop.co.uk/home

redirects to:

http://dev.shop.co.uk/index.php/home
Profile
 
 
Posted: 30 January 2008 05:08 PM   [ Ignore ]   [ # 10 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19292
Joined  06-03-2002

Right, that wouldn’t set any GET variables.  Your URL would need to be something like:

http://example.com/index.php?/home

for that code to fire off.  Can you copy and paste your .htaccess here?

 Signature 
Profile
MSG
 
 
Posted: 30 January 2008 05:11 PM   [ Ignore ]   [ # 11 ]  
Grad Student
Avatar
Rank
Total Posts:  95
Joined  03-05-2006

Ah. It becomes clear all of a sudden…

RewriteEngine On

RewriteBase
/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond
%{REQUEST_FILENAME} !-d
RewriteRule
^(.*)$ index.php?/$1 [L]


...that’ll be that question mark, then. Feel free to beat me to death with a copy of Woman’s Weekly.

Profile
 
 
Posted: 30 January 2008 05:16 PM   [ Ignore ]   [ # 12 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19292
Joined  06-03-2002

::looks around for a copy of Woman’s Weekly::

::gives up::

Looks like you’re safe for now. wink

 Signature 
Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120328 Total Logged-in Users: 55
Total Topics: 126450 Total Anonymous Users: 6
Total Replies: 664941 Total Guests: 506
Total Posts: 791391    
Members ( View Memberlist )