Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9251985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:50:06+00:00 2026-06-18T10:50:06+00:00

I’m trying to achieve the following URLs for my API (I’m using Codeigniter and

  • 0

I’m trying to achieve the following URLs for my API (I’m using Codeigniter and Phil Sturgeon’s REST server library):

/players            -> refers to index method in the players controller
/players/rookies    -> refers to rookies method in the players controller

I don’t want the URL to have a trailing “index”

/players/index

This is no problem at all when I define the routes like so:

$route['players'] = 'players/index';

Everything works as expected.

My problem is that I need additional URL segments like so:

/players/rookies/limit/10/offset/5/key/abcdef

The above example works, but the following does not:

/players/limit/10/offset/5/key/abcdef

I’m getting the following error: {"status":false,"error":"Unknown method."}
Obviously there is no limit method in my controller.

How do I have to setup my routes.php config file to get these URLs to work properly?

Any help is much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:50:07+00:00Added an answer on June 18, 2026 at 10:50 am
    //www.mysite.com/players
    $route['players'] = 'players/index_get';//initial call to players index
    
    //www.mysite.com/players/rookies
    /** overrides the above **/
    $route['players/(:any)'] = 'players/index_get/$1';//Changing defaults index
    
    //www.mysite.com/players/rookies/10/4
    /** overrides the above **/
    $route['players/(:any)/(:num)/(:num)'] = 'players/index_get/$1/$2/$3';//Changing type,limit,offset
    
    //All routes that are similar, like above that follow the previous, override the preceding one. 
    
    
    //www.mysite.com/players/create
    //overrides $route['players/(:any)']
    $route['players/create'] = 'players/index_post';
    
    
    class Players extends REST_Controller
    {
        public $player_types = array();
    
        public function __construct(){
           $this->player_types = array(
              'rookies', 'seniors'
           );//manual assign or pull from db
        }
        /**
         * Index
         * $_GET
        **/
        public function index_get($type='rookies',$offset=0, $limit=0)//some defaults to show on initial call
        {
            // www.mysite.com/players/rookies
            // $route['players/(:any)'] = 'players/index_get/$1';
            // First uri segment, check to see if its a valid player 'type'
    
            if(!in_array(strtolower($type), $this->player_types)){
                 //redirect ?
                 return;
            }
        }
        /**
         * Index
         * $_POST
        **/
        public function index_post()
        {
            // Create a new player
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am using JSon response to parse title,date content and thumbnail images and place

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.