Part of the EllisLab Network
   
 
Optionally enable standard query string based URLs
Posted: 14 March 2009 02:04 PM   [ Ignore ]  
Summer Student
Total Posts:  12
Joined  12-04-2007

I have been trying to get only ONE of my functions to load with standard query string with no luck. I played with both the config and route files only to come with more errors. If anyone has any suggestions I would appreciate it smile

URL
www.your-site.com/class/function?c=controller&m=function

route.php

$route['class/function?:any'] = "class/function/$1";

config.php

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-?=&';
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
Profile
 
 
Posted: 14 March 2009 02:29 PM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4839
Joined  07-14-2006

I think you better convert the query string of the method in a pre_system hook.

function get_to_segments()
{
   
if(substr($_SERVER['PATH_INFO'],1) == 'controller/method')
   
{
       header
('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'/'.implode('/',$_GET));

       exit;
   
}
}

Then you don’t have to enable the query strings and you don’t have to add extra characters to the allowed_characters setting.

Profile
 
 
Posted: 14 March 2009 03:12 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  12
Joined  12-04-2007

Thanks XWERO.. You are always here to help us Newbs out. You should change your SN to xHERO. smile

Profile
 
 
Posted: 20 April 2009 02:20 AM   [ Ignore ]   [ # 3 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2690
Joined  05-18-2008

Thanks Xwero, I was wondering how to get a nice, clean combination of URI segments and query strings smile

 Signature 

I’m building a Project Management System for my 3rd year Uni project, Sign up to the beta
Track my progress | Post of the day: UI Designs
Get full auto complete support for CodeIgniter in Eclipse

Profile
 
 
Posted: 20 April 2009 02:37 AM   [ Ignore ]   [ # 4 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4839
Joined  07-14-2006

the code doesn’t mix path segments with query strings. It processes the query string to path segments before it reaches CI. The function is meant to be used when you want your app to have all path urls.

If you want to prevent CI from fetching the query string you set the uri_protocol to path_info/orig_path_info/request_uri. When you need the query string in one of your methods you just add

parse_str($_SERVER['QUERY_STRING'],$_GET);

and you can use the global.

Profile
 
 
Posted: 18 May 2009 07:20 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  1
Joined  05-18-2009

thanks for this thread,it helped me a lot

 Signature 

jocuri

Profile
 
 
Posted: 18 May 2009 07:19 PM   [ Ignore ]   [ # 6 ]  
Lab Technician
RankRankRankRank
Total Posts:  1238
Joined  04-19-2008

Nice. This might be helpful to me someday smile bookmarked.

EDIT: So this thing redirects to the ‘correct’ path whenever it encounters the query string your looking for. Maybe it should be noted that this only works when you set the uri_protocol to PATH_INFO and ORIG_PATH_INFO.

 Signature 

...

Profile
 
 
Posted: 14 September 2009 06:30 PM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  8
Joined  03-27-2009

This is awesome. It really should be in the user guide.

Profile
 
 
Posted: 25 September 2009 01:45 AM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  8
Joined  03-27-2009

This breaks with the 1.7.2 upgrade under php 5.3

A PHP Error was encountered

Severity
: Notice

Message
: Undefined index: PATH_INFO

Filename
: hooks/hooks.php

Line Number
: 5
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 721, on January 06, 2010 09:38 AM
Total Registered Members: 115022 Total Logged-in Users: 73
Total Topics: 122459 Total Anonymous Users: 6
Total Replies: 647355 Total Guests: 493
Total Posts: 769814    
Members ( View Memberlist )