How to codeigniter remove index.php on Windows Server and IIS?

How to codeigniter remove index.php on Windows Server and IIS?

In this post we will show you codeigniter remove index.php on Windows Server and IIS, hear for codeigniter remove index.php on Windows Server and IIS we will give you demo and example for implement.

steps for codeigniter remove index.php on Windows Server and IIS

Step :- 1) Go to application/config and open the file config.php.

Find and Replace the following code in config.php file.

//  Find following code
$config['index_page'] = "index.php";
 
// And Remove index.php
$config['index_page'] = "";

Step :- 2) Go to your codeigniter directory(root directory) and create/add web.config file.

Path of directory :-

codeigniter_projct/
web.config <--- create/add file hear(on root)
index.php
application/
assets/
system/

Step :- 3) Add following code in web.config file.
If URL Rewrite module is not installed, please install it from here http://www.iis.net/downloads/microsoft/url-rewrite
Please check the complete web.config file. Place this in the same folder where the index.php is placed.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll">
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
          </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Step :- 4) In some cases of default setting does not work properly for uri_protocol . To resolve this issue Go to application/config and open the file config.php.Find and Replace the following code in config.php file:

config.php file

//  Find the following code
$config['uri_protocol'] = "AUTO"; // AUTO to REQUEST_URI
//  Replace it as
$config['uri_protocol'] = "REQUEST_URI"; // AUTO to REQUEST_URI

Its working in IIS in Windows server 2008 R2

Hope this code and post will helped you for implement codeigniter remove index.php on Windows Server and IIS. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org

1 thought on “How to codeigniter remove index.php on Windows Server and IIS?”

Leave a Comment

Your email address will not be published. Required fields are marked *

1  +  3  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US