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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:46:03+00:00 2026-06-12T09:46:03+00:00

Followed a tutorial to remove index.php from the URLs in Code Igniter . It

  • 0

Followed a tutorial to remove index.php from the URLs in Code Igniter.

It works now for my default_controller, but not for other pages(or views) properly.

I have one controller, Pages, and it has one method, View($page = ‘home’), to load pages with other content based on the parameter passed.

If I type localhost/dev into URL – I land on my home page, which is correct.

If I type localhost/dev/aboutus – I receive 404. It only works if I type localhost/dev/pages/view/aboutus.

What I wanted to happen is by typing localhost/dev/aboutus it would show me the AboutUs view.

Routes.php

$route['default_controller'] = "pages/view";
$route['dev/(:any)'] = "dev/pages/view/$1";
$route['404_override'] = '';

Pages.php (controller)

<?php
    class Pages extends CI_Controller
    {
        public function view($page = 'home')
        {
            if (!file_exists('application/views/pages/' . $page . '.php'))
            {
                // Whoops, we don't have a page for that!
                show_404();
            }

            $data['title'] = ucfirst($page); // Capitalize the first letter

            $this->load->view('templates/header', $data);
            $this->load->view('pages/' . $page);
            $this->load->view('templates/footer');
        }
    }
?>

.htaccess file (located in /dev/ folder)

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /dev/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule> 
  • 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-12T09:46:05+00:00Added an answer on June 12, 2026 at 9:46 am

    This route $route['dev/(:any)'] = "dev/pages/view/$1"; is a little fishy because CodeIgniter routes should not include the project name (dev in your case). They begin on the controller level, not the project one.

    The route you have written would imply that if a user typed http://localhost/dev/dev/something (yes, two dev’s) they would be routed to a controller dev.php and into a function with prototype: function('view', 'something'){}

    Why so complicated? You should make all of your main page names into controllers. Routes should only be touched for special cases.

    Create a file aboutus.php in application/controllers with contents:

    <?php
    class Aboutus extends CI_Controller{
        function __construct(){
            parent::__construct();
        }
    
        function index(){
            "I'm in the about controller!";
            //$this->load->view("some_view") ;
        }
    }
    

    You can access it with http://localhost/dev/aboutus

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

Sidebar

Related Questions

I followed a tutorial to create a scrollbar template from this site: http://sachabarber.net/?p=122 But
I followed this tutorial . But whenever I try to log in with my
I followed this tutorial http://stevejenkins.com/blog/2011/08/how-to-install-apc-alternative-php-cache-on-centos-5-6/ to install apc on my centos vps hosting but
I followed this tutorial here: http://www.dannyherran.com/2011/02/facebook-php-sdk-and-codeigniter-for-basic-user-authentication/ It works great but when I enable CSRF
i've followed the pagination tutorial from http://framework.zend.com/manual/en/zend.paginator.usage.html I have successfully implemented pagination for my
I followed this tutorial , and I wrote the following code in FirstViewController.m: -
I have followed a tutorial to create a simple blog writing application in PHP
Ok, sorry if this question is stupid. I followed this tutorial: http://www.youtube.com/watch?v=E30_-pQGQXs . Now
I followed the official Authlogic tutorial but something came up. I successfully created a
I've followed the spring http proxying tutorial as closely as possibly, but I still

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.