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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:21:29+00:00 2026-06-08T01:21:29+00:00

I’m creating an app in CakePHP which requires me to run ‘multiple’ apps within

  • 0

I’m creating an app in CakePHP which requires me to run ‘multiple’ apps within one CakePHP installation. Something like I have n controllers that behave the same for all applications, but they only differ when I call the database – anyway, I need to create a route which behaves something like this:

/app1/controller/action/a/b/c
/app2/controller/action/a/b/c

(where app1 and app2 are alphanumeric strings that can change to anything)

That would be routed to something like:

/controller/action/app1/a/b/c

(or the same for app2, and so on)

The routed route could be just /controller/action/a/b/c too, but I need to have a way to access the app1 / app2 parts of the URL within the controller (for further processing within the controller). Is there a way to do this in CakePHP? Thanks.

Slightly related question: When the above is accomplished, is there a way to set a ‘default’ app-name (like when I attempt to access /controller/action/a/b/c it will automatically be routed to the equivalent of typing /global/controller/action/a/b/c?)

Thanks!

Effectively: What I want is just to use Routing (or any other CakePHP ‘method’ that can do this) to handle URLs like /foobar/controller/action/the/rest to /controller/action/the/rest and pass “foobar” to the controller, somehow. “Foobar” is any alphanumeric string.

  • 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-08T01:21:31+00:00Added an answer on June 8, 2026 at 1:21 am

    In app/Config/routes.php add:

    Router::connect( 
        '/:app/:controller/:action/*', 
        array(), 
        array( 'pass' => array( 'app' ))
    );
    

    This will pass the value of app as the first argument to the action in your controller. So in your controller you would do something like:

    class FoosController Extends AppController {
        public function view_something($app, $a, $b, $c) { 
            // ...
        }
    }
    

    When you request /myApp1/foos/view_something/1/2/3 the value of $app would be 'myApp1', the value of $a would be 1, etc.

    To connect other routes, before the above, you can add something like:

    Router::connect(
        '/pages/:action/*',
        array( 'app' => 'global', 'controller' => 'pages' ),
        array( 'pass' => array( 'app' )) // to make app 1st arg in controller
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

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.