I downloaded Code Igniter 3.1.7 and am hosting my website on IIS 8. However; I am currently at a stop due to an irritating problem which I have been trying to solve.
My goal is to remove 'index.php' from url when trying to access a controller.
Example: http://localhost/welcome instead of http://localhost/index.php/welcome
Since IIS does not use the htaccess file to create a rule to remove 'index.php' from url. An alternative I tried to do is to use the URL Write add-on provided by IIS.
After I hit Apply. The web.config file is created:
<?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="{R:1}" pattern="^(index\.php|assets|images|js|css|uploads|favicon.png)" ignoreCase="false" negate="true" />
<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}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Then I went to application/config/config.php file and changed these variables:
$config['base_url'] = '';
to $config['base_url'] = 'http://localhost/';
$config['index_page'] = 'index.php';
to $config['index_page'] = '';
Afterwards, I try to access using http://localhost/welcome , But I get this message:
404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.