Removing index.php in Codeigniter using XAMPP on Windows

Using the method below, you can access your site http://localhost/Mysite/index.php/welcome without the index.php like this: http://localhost/Mysite/welcome

I did this in Code Igniter 2.0.3 using XAMPP 1.7.1 on Windows 7.

Create .htaccess file in the root folder of code igniter. I got the code below from http://codeigniter.com/wiki/mod_rewrite/. Make sure you use your site folder name in Rewrite Base below:

    RewriteEngine On
    RewriteBase /Mysite/

    #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]


    # 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  

In config.php within the application folder, set index_page as blank:
$config['index_page']    = '';

In the same file, make sure uri_protocol is set to this:
$config['uri_protocol']    = 'AUTO';

If the above does not work, you may try this:
$config['uri_protocol']    = 'REQUEST_URI';

Comments

  1. your htaccess working fine nice way to explain i spen lot of time to search remove index.php in codeigniter. u save my time thank you

    ReplyDelete
  2. Thanks it worked for me

    ReplyDelete
  3. Thank you buddy... It's worked for me.

    ReplyDelete
  4. Thanks it worked for me as well....

    ReplyDelete

Post a Comment

Popular posts from this blog

How to resolve 'res://ieframe.dll/acr_error.htm#' error (Internet Explorer stopped working while viewing a website)

htaccess: Redirecting multiple domains to the main domain