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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:24:18+00:00 2026-06-02T04:24:18+00:00

I have a controller setup to accept two vars: /clients/view/var1/var2 And I want to

  • 0

I have a controller setup to accept two vars: /clients/view/var1/var2

And I want to show it as /var1/var2

SO i tried

Router::connect('/*', array('admin'=>false, 'controller' => 'clients', 'action' => 'view'));

But this stops all other controllers working as /* routes everything

All other pages that are on the site are within the admin prefix so basically i need a route that is ignored if the current prefix is admin! I tried this (regex is from Regular expression to match a line that doesn't contain a word?):

Router::connect('/:one', array('admin'=>false, 'controller' => 'clients', 'action' => 'view'), array(
    'one' => '^((?!admin).*)$'
));

But I think the regex is incorrect because if i naviate to /test it asks for the tests controller, not clients

My only other routes are:

Router::connect('/admin', array('admin'=>true, 'controller' => 'clients', 'action' => 'index'));
Router::connect('/', array('admin'=>false, 'controller' => 'users', 'action' => 'login'));

What am I doing wrong? Thanks.

  • 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-02T04:24:22+00:00Added an answer on June 2, 2026 at 4:24 am

    I misunderstood your question the first time. I tested your code and didn’t get the expected result either. The reason might be that the regex parser doesn’t support negative lookahead assertion. But I still think you can solve this with reordering the routes:

    The CakeBook describes which routes are automatically generated if you use prefix routing. In your case these routes have to be assigned manually before the ‘/*’-route to catch all admin actions. Here is the code that worked for me:

    // the previously defined routes
    Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
    Router::connect('/admin', array('controller' => 'clients', 'action' => 'index', 'admin' => true));
    
    // prefix routing default routes with admin prefix
    Router::connect("/admin/:controller", array('action' => 'index', 'prefix' => 'admin', 'admin' => true));
    Router::connect("/admin/:controller/:action/*", array('prefix' => 'admin', 'admin' => true));   
    
    // the 'handle all the rest' route, without regex
    Router::connect(
        '/*', 
        array('admin'=>false, 'controller' => 'clients', 'action' => 'view'), 
        array()
    );
    

    Now I get all my admin controller actions with the admin prefix and /test1/test2 gets redirected to the client controller.

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

Sidebar

Related Questions

A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
In my controller I have model operations that can return empty results. I've setup
I have a Spring controller that returns XHTML, what's the easiest way to setup
I have controller with action new , and I want it to create ActiveRecord::Base
I have controller PlayerController and actions inside: View , Info , List . So
Hi guys i have controller which returns a partial view, the controller is called
I have an ASP.NET MVC2 application that uses a parent controller to setup specific
i have setup a preDispatch plugin for my ACL. i have used the controller
I have my controller Setup my join_model and my login_model A user registers and
I'm running CodeIgniter 2.0 and I have a test controller setup with this code

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.