Unable to remove index.php on IIS 10 - travdog95 - 10-06-2018
I have had no luck removing index.php from site's URL. I'm upgrading to 3.1.9 from 2.1.4, and any URL rewrite I try in my web.config file gives me a 500 error. My setup is:- Windows Server 2016
- IIS 10
- PHP 7.1
In addition, the only way to get any controller to load, besides my default controller, is to make the following adjustment in my config.php file:
Code: $config['index_page'] = 'index.php?';
I got that from the Codeigniter troubleshooting page. https://www.codeigniter.com/user_guide/installation/troubleshooting.html
Any help on either issue would be greatly appreciated.
RE: Unable to remove index.php on IIS 10 - php_rocs - 10-08-2018
@travdog95,
Try this ... https://www.codeigniter.com/user_guide/general/urls.html?highlight=remove%20index%20php#removing-the-index-php-file
RE: Unable to remove index.php on IIS 10 - travdog95 - 10-08-2018
(10-08-2018, 07:19 AM)php_rocs Wrote: @travdog95,
Try this ... https://www.codeigniter.com/user_guide/general/urls.html?highlight=remove%20index%20php#removing-the-index-php-file
I appreciate the response, but this is the first place I went. The URL rewrite on this page refers to Apache. I have it working correctly in my existing environments (see below), but I need to upgrade OS, IIS, SQL Server, PHP and Codeigniter.
Current Environment:- Windows Server 2012
- IIS 7
- PHP 5.3
- CodeIgniter 2.1.4
New Environment- Windows Server 2016
- IIS 10
- PHP 7.1
- CodeIgniter 3.1.9
The web.config file on my current environment doesn't work on the new one. And anything I've found searching the Internet hasn't worked either.
RE: Unable to remove index.php on IIS 10 - jreklund - 10-08-2018
Hi, can you post your web.config?
RE: Unable to remove index.php on IIS 10 - travdog95 - 10-08-2018
Code: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<remove value="index.htm" />
<remove value="Default.htm" />
<remove value="Default.asp" />
<remove value="iisstart.htm" />
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Remove Index.php" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<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>
RE: Unable to remove index.php on IIS 10 - travdog95 - 10-08-2018
I think I need to solve my URI_PROTOCOL problem first. Without setting $config['index_page'] = "index.php?", I can't get any page to load except the default page. Like the documentation says, I've rotated through all the possible options for URI Protocol, but none of them work. I was using "Auto" in my old environments.
Code: /*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string. The default setting of 'REQUEST_URI' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'REQUEST_URI' Uses $_SERVER['REQUEST_URI']
| 'QUERY_STRING' Uses $_SERVER['QUERY_STRING']
| 'PATH_INFO' Uses $_SERVER['PATH_INFO']
|
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
$config['uri_protocol'] = 'REQUEST_URI';
Because none of these options worked, I added a "?" to my index.php as recommended by the troubleshooting page: https://www.codeigniter.com/user_guide/installation/troubleshooting.html
RE: Unable to remove index.php on IIS 10 - snelledre - 10-08-2018
This is my web.config file.
Place it in the root, it's working for me with ISS with sql-server 2014 and 1016
Code: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="MainFolder" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
RE: Unable to remove index.php on IIS 10 - jreklund - 10-08-2018
Hi, try this one instead.
Code: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<remove value="index.htm" />
<remove value="Default.htm" />
<remove value="Default.asp" />
<remove value="iisstart.htm" />
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Remove Index.php" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<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>
RE: Unable to remove index.php on IIS 10 - travdog95 - 10-08-2018
Thanks @jreklund and @snelledre. I'll give those a try later today. Any thoughts on my URI Segment issue?
RE: Unable to remove index.php on IIS 10 - jreklund - 10-08-2018
appendQueryString="true" in my web.config should solve that one.
|