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

  • Home
  • SEARCH
  • 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 663463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:29:32+00:00 2026-05-13T23:29:32+00:00

Is it possible in CakePHP to have URL aliases in routes.php? Or by what

  • 0

Is it possible in CakePHP to have URL aliases in routes.php? Or by what other means can achieve something equivalent:

Lets assume I have some paginated views. Among the possible orderings there are particular ones I want to bind to a simple URL. E.g.:

  • http://example.com/headlines => http://example.com/posts/listView/page:1/sort:Post.created/direction:desc
  • http://example.com/hottopics => http://example.com/posts/listView/page:1/sort:Post.view_count/direction:desc etc.

How do I add parameters to a Router::connect()? Pseudo code:

Router::connect('/'.__('headlines',true),
        array(
        'controller' => 'posts',
        'action' => 'listView'
        'params' => 'page:1/sort:Post.created/direction:desc',
        )
);
  • 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-05-13T23:29:32+00:00Added an answer on May 13, 2026 at 11:29 pm

    Note that the Router “translates” a URL into Controllers, Actions and Params, it doesn’t “forward” URLs to other URLs. As such, write it like this:

    Router::connect('/headlines',
        array(
            'controller' => 'posts',
            'action' => 'listView'
            'page' => 1,
            'sort' => 'Post.created',
            'direction' => 'desc'
        )
    );
    

    I don’t think '/'.__('headlines', true) would work, since the app is not sufficiently set up at this point to translate anything, so you’d only always get the word in your default language back. Also, you couldn’t switch the language anymore after this point, the first use of __() locks the language.

    You would need to connect all URLs explictly. To save you some typing, you could do this:

    $headlines = array('en' => 'headlines', 'de' => 'schlagzeilen', ...);
    foreach ($headlines as $lang => $headline) {
        Router::connect("/$headline", array('controller' => ..., 'lang' => $lang));
    }
    

    That will create a $this->param['named']['lang'] variable, which you should use in the URL anyway.

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

Sidebar

Related Questions

I have a CakePHP project where I modified app/config/routes.php so that the root points
Is it possible to do domain-specific routes in cakephp? for example, let's say I
I am building a PHP application with CakePHP 2 . I need to have
I'm new to cakephp...and I have a page with a url this: http://localhost/books/filteredByAuthor/John-Doe so
I have a PHP SOAP web service, using CakePHP, which is returning a variable
Is it possible to have a nested ajax form in cakephp and firefox ?
In CakePHP, Is it possible to insert into another table with the other model
Is batch insertion of records possible in cakephp ? Kindly reply me if possible
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
I have a website made with CakePHP 1.3.7. This website has it's own login

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.