Codeigniter路由为静态页面主页工作其他路由而不是页面

When I access localhost:8080/ignite_me it shows me contents of home.php with header and footer but when I try localhost:8080/igniteme/test It gives me Apche 404 page and test.php exist in my views/pages where i have put my home.php

even localhost:8080/igniteme/home is not working but localhost:8080/igniteme shows content of home.php

routes.php

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

Pages.php

<?php
class Pages extends CI_Controller {

    public function _construct()
    {
        parent::_construct();
    }

        public function view($page = 'home')
        {
            if ( ! file_exists(APPPATH.'/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, $data);
            $this->load->view('templates/footer', $data);
        }
}

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

config.php

$config['base_url'] = 'http://localhost:8080/igniteme/';
$config['index_page'] = '';

I am unable to understand why home.php works with localhost:8080/ignite_me and why not with localhost:8080/igniteme/home or any other page is not working I have copied .htaccess from some other stack overflow question it was not working even with default one.

here is link to my complete codeignite folder igniteme

I am using wamp I use this htaccess below

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Make sure in main directory.

Also in wamp make sure YOU HAVE ENABLED APACHE MOD REWRITE

Scroll/click and go down the list to you find rewrite_module click on it then go and restart wamp.

enter image description here

Lets Start With Simple Approach

I am assuming that ignite_me is your project folder and in views folder you have two files test.php and home.php and by default there is welcome.php file.

Now Starting Configure Your routes

1.First when you hit the url with localhost:8080/ignite_me it shows you welcome.php file

As there is a controller for welcome
Now first decide which controller you want to make default let assume you have set controller to test so every time you hit url test view will open
for configuration like this

In routes.php

$route['default_controller'] = "test";

Now every time it refers to views test.php
if you want to access like this
localhost:8080/ignite_me/index.php/test.php it redirect to same

Now for Removing index.php we should use .htaccess file in

.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Now you can access it again
localhost:8080/ignite_me/index.php/test.php it gives you 404 not found error
localhost:8080/ignite_me/test.php it gives you that page

Genereal Ways for route is

localhost:8080/ignite_me/[controller]/views

try this

$config['base_url'] = 'http://localhost:8080/igniteme/';
$config['index_page'] = 'index.php';

I ran into a similar issue when I moved a codeigniter 2 app from a xampp in windows to a ubuntu server 14.04 LTS

my .htaccess file:

RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

$config['index_page'] = ''; //blank so index.php wouldn't show inline with .htaccess file

I had routes enable and was getting a 404 on everything but my welcome controller

What I did was to make sure mod_rewrite was enable and set the following configuration on /etc/apache2/sites-available/000-default.conf

Right under “DocumentRoot /var/www/html” add the following lines below:

<Directory "/var/www/html">
    AllowOverride All
</Directory>

Save and exit the nano editor via CTRL-X, “y” and ENTER.

And restart the service: sudo service apache2 restart

Hope it does the trick for you