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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:34:34+00:00 2026-05-15T23:34:34+00:00

Say I have a controller, Articles but I want it to appear as a

  • 0

Say I have a controller, “Articles” but I want it to appear as a sub-folder (e.g. “blog/articles”), I can add a route like this:

$route['blog/articles'] = 'articles';
$route['blog/articles/(:any)'] = 'articles/$1';

This works fine, the only problem now is that example.com/articles and example.com/blog/articles both use the Articles controller and thus resolve to the same content. Is there a way to prevent this?

To add a little more clarity in case people aren’t understanding:

  • In this example, I don’t have a ‘blog’ controller, but I want ‘articles’ etc to appear to be in that subfolder (it’s an organization thing).
  • I could have a blog controller with an ‘articles’ function, but I’m likely to have a bunch of ‘subcontrollers’ and want to separate the functionality (otherwise I could end up with 30+ functions for separate entities in the blog controller).
  • I want example.com/articles to return a 404 since that is not the correct URL, example.com/blog/articles is.
  • 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-15T23:34:35+00:00Added an answer on May 15, 2026 at 11:34 pm

    Shove this in your controller:

    function __construct()
    {
        parent::Controller();
    
        $this->uri->uri_segment(1) == 'blog' OR show_404();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say i have a Controller like this one : @RequestMapping(method=RequestMethod.GET, value=/error) public void
Lets say I have a controller class like this. public class InStorePickupController : Controller
Say I have a class ObjectA (a view controller for example), that does this
Let's say I have a simple ASP MVC3 list controller, with an add method,
How to add more than one parameter in Twig path? Say you have this
I have urls that look like this ~\articles\energy\topweek ~\articles\metals\latestpopular where second url string is
In django, can I have 2 controller actions with the same name, but one
I know this has been asked before but I can't find it so... Say
Let's say I have an async controller like that below ~ public class HomeController
Lets say I have this in my controller @appointment.add_appointer Is there a shortcut in

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.