How to remove index.php in codeigniter on Windows Server and IIS?
I found this when i search for answer
How to rewrite the index.php of Codeignite
Make web.config put in the root directory.
User code:
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<rewrite>
<rules>
<rule name="RuleRemoveIndex" 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" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true"/>
</rule>
</rules>
</rewrite>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
You should upload the web.config file with your project and write the code
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="Hide Yii Index" 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" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
If You are still getting the problem then go through the following link
PHP MVC Framework IIS index.php solution
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>
Its working in IIS in Windows server 2008 R2
This answer is a little more secure (paranoid) than the others, and is based on the way CakePHP does it. This assumes that you have a directory named "public" which contains all of the js, css, image, and font files. If you have other extensions you want to allow, add them to the second rule. You can change the directory name from "public" to anything be replacing the word "public" in rule 1 and 2.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Exclude direct access to public/*" stopProcessing="true">
<match url="^public/(.*)$" ignoreCase="false" />
<action type="None" />
</rule>
<rule name="Rewrite routed access to assets by extension" stopProcessing="true">
<match url="^(.*)(\.(css|js|otf|eot|svg|ttf|woff|woff2|jpg|png|gif|ico))$" />
<action type="Rewrite" url="public/{R:1}{R:2}" appendQueryString="false" />
</rule>
<rule name="Rewrite requested file/folder to index.php" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>