Part of the EllisLab Network
   
 
mod_rewrite, CI and commas in URI’s
Posted: 09 May 2006 09:00 AM   [ Ignore ]  
Summer Student
Total Posts:  1
Joined  05-09-2006

I’m writing my first CI application, and would like to use URI’s as the following:

http://www.domain.com/users/3,10,a,3

which would be; “list of 10 users starting from id 3, sorted ascending on field #3” (obviously the last (3) could be the name of the field).

I’m trying to do this with mod_rewrite, leaving CI alone as much as I can. Current RewriteRule

^issues/([0-9]+),([0-9]+),(a|d|),([0-9]*)$    /index.php/issues/get/from/$1/to/$2/order/$3/field/$4    [L]

allows for ‘users/3,10,,’ and CI would see:

http://www.domain.com/users/from/3/num/10/order//field/

The problem now comes with uri_to_assoc() which gives the following:

Array
(
    
[from] => 1
    [to]
=> 2
    [order]
=> field
)

The last bit is obviously not correct.

Googling didn’t help, but does somebody know how to let mod_rewrite set a default value for a ‘$X’ if it matched on the ‘empty_string’ ?

Profile
 
 
Posted: 09 May 2006 10:03 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  130
Joined  04-14-2006

Why don’t you just do it in PHP?

if (preg_match('/^([0-9]+),([0-9]+),(a|d|),([0-9]*)$/', $this->uri->segment(2), $matches)) {
   $from  
= $matches[1];
   
$to = $matches[2];
   
$order = $matches[3];
   
$field = $matches[4];
}

 Signature 

CIForge.com - CodeIgniter Community Source Hosting

Profile
 
 
   
 
 
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 719, on June 06, 2008 10:16 AM
Total Registered Members: 61048 Total Logged-in Users: 11
Total Topics: 73849 Total Anonymous Users: 0
Total Replies: 398354 Total Guests: 282
Total Posts: 472203    
Members ( View Memberlist )
Active Members:    Dark PreacherDyaGaesraJoostVmatthinckleymironchophantom-aSumonthurtingWeblizardwiredesignz