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 8529855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:07:26+00:00 2026-06-11T09:07:26+00:00

I am using cakephp 1.3. here’s my problem: I have a controller named learns

  • 0

I am using cakephp 1.3. here’s my problem:

I have a controller named “learns” and a method named “classroom”.

To access the classroom method, I use this link: http://www.url.com/learns/classroom/15

I wanted it to be like this: http://www.url.com/class/15

And this is how I setup the routes:

Router::connect('/:class/:id', array('controller' => 'learns', 'action' => 'classroom'), array('id' => '[0-9]+'));

I don’t really know why its not working though. I read through the documentation and I just copied this solution from the cookbook..

Thanks for the help in advance.

  • 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-11T09:07:28+00:00Added an answer on June 11, 2026 at 9:07 am

    I don’t see anything wrong with your Router statement. Though I am not sure if you actually wanted /:class/:id instead of “/class/:id“. See the difference? A Colon is missing in the 2nd version.

    This tells the Router that any request that begins with /class/[an-id] should be mapped to whatever your rule is. Where as having it as /:class means you are passing an argument to the router. It can be anything /foo/15 or /bar/15 and these arguments will be available in your $this->params[‘class’] and $this->params[‘id’]., assuming this rule -> /:class/:id

    In your question you state that “I don’t really know why its not working”. Please avoid these kind of statements as it does not say any thing about the actual problem.

    Instead tell us what were you expecting? And what did you see instead? Was it an error? Or a Warning? If you see something else entirely, for example a different action got executed, it is probably due to the fact how routers actually work. If you had a greedy route and a normal route like this:

    /users/* and
    /users/:id

    The second url will not be matched for any request as /users/* is greedy and will hog all the requests to itself, unless the first routing rule returns false.

    If this is your situation I would suggest you read up on how to write custom route classes. In summary custom route classes try to make a greedy route less greedy. For a better explanation here is an excellent article by mark story: http://mark-story.com/posts/view/using-custom-route-classes-in-cakephp

    Routing in cakephp is one of the most confusing topics and might take a while before you get your head around it. Cookbook is your best friend. Read and Re-read everything until you are sure what each routing element does in a routing rule.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Cakephp as my framework. I have a problem in uploading my
I am using cakePHP 1.26. In the PostsController, I have this: $this->paginate=array('conditions'=>array('Reply.post_id'=>$id),'limit' => 1);
I'm using CakePHP to send an email. My controller code looks like: if ($this->User->save($this->request->data))
I am building a portfolio website using CakePHP and have named my model 'Portfolio'
I'm struggling to find the answer to this. I have only been using CakePHP
Im using cakephp 2.0 and i have data submitted that i want to cleanup,
I'm using cakephp 2.1.3 and I have a table Ingredients and a table IngredientAliases
I am using CakePHP 2.1 and I am having this tag in my program..
I am using CakePHP and want to create a URL to a controller/view without
I'm using CakePHP 2.1 I have following fields in database. id views max_views I

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.