Pages

Search This Blog

Thursday, October 16, 2014

404 - File or directory not found. when use codeigniter in windows iis

Facing error message when deploy codeigniter php site to windows server 2013 (iis8)


404 - File or directory not found.

The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.


The main issue is because of the url rewrite doesn't work in IIS without proper setting in web.config (IIS doesn't read .htacess)

What we need to do is open web.config

Add code below into the correct


<rewrite>
  <rules>
    <rule name="Rule" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
        <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
    </rule>
  </rules>
</rewrite> 

>


If you are want to create the new web.config without others configuration, the web.config shoud looks like this

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<system.webServer>

    <httpErrors errorMode="Detailed" />
    <asp scriptErrorSentToBrowser="true"/>

   <rewrite>
  <rules>
    <rule name="Rule" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
        <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
    </rule>
  </rules>
</rewrite> 

</system.webServer>


</configuration> 
Hope this helps




1 comment:

Elakiya Samuel said...

Tanks man. big help. its awesome :)