7

I want to remove the index.php in the URL but it doesn't work. Here's what I did:

  1. I enable the rewrite_module in my Apache then restart server
  2. I edit the .htaccess in my codeigniter folder. I add this according to the example in the documentation.

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php/$1 [L]

  3. Then I also remove the index.php in app/config

  4. Then I create a simple controller:

    class Users extends CI_Controller {
    
        public function __construct() {
            parent::__construct();
        }
    
        public function index() {
            echo "hello world";
        }
    
    }
    

And when I access this URL:

http://localhost/order_menu/users

I got this error:

Not Found

The requested URL /order_menu/users was not found on this server.

Can you help me with this?

3
  • Are you using wamp server? And have you set up some routes in config/routes.php Commented Sep 15, 2015 at 1:31
  • I am using wamserver. In my routes I have the default of CodeIgniter Commented Sep 15, 2015 at 1:33
  • Have you enabled rewrite mod in wamp? Commented Sep 15, 2015 at 1:35

1 Answer 1

7

Removing index.php in codeigniter on wamp apache server!

When your using wamp make sure you have enabled Apache Modules "rewrite_module" restart server

Second

Try this htaccess in main directory of project

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]

Then go to application/config/config.php

Find $config['index_page'] = 'index.php';

And then make index.php blank

Replace With $config['index_page'] = '';

You may need to configure your routes

CI3: http://www.codeigniter.com/user_guide/general/routing.html

CI2: http://www.codeigniter.com/userguide2/general/routing.html

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer. And some guidelines.. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.