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

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

I found this when I was looking for an answer

How to rewrite codeigniter index.php on Windows Azure

but when I try to execute my CI, you need to execute index.php to run which web.config file should be added, and is there any other step before I edit the web.config file?

+8
iis codeigniter windows-server-2003
source share
3 answers

If the Rewrite URL module is not installed, please install it here http://www.iis.net/downloads/microsoft/url-rewrite

Please check the full web.config file. Put this in the same folder where index.php is located.

<?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> 

Works in IIS on Windows Server 2008 R2

+15
source share

This answer is slightly safer (paranoid) than others, and is based on how CakePHP does it. This assumes that you have a directory called "public" that contains all the js, css, image and font files. If you have other extensions that you want to allow, add them to the second rule. You can change the directory name from "public" to something by replacing the word "public" in rules 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> 
0
source share

You must download 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, click on the following link

PHP MVC Framework IIS solution index.php

0
source share

All Articles