Welcome Guest, Not a member yet? Register   Sign In
Unable to remove index.php on IIS 10
#1

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/i...oting.html

Any help on either issue would be greatly appreciated.
Reply
Reply
#3

(10-08-2018, 07:19 AM)php_rocs Wrote: @travdog95,

Try this ... https://www.codeigniter.com/user_guide/g...x-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.
Reply
#4

Hi, can you post your web.config?
Reply
#5

(This post was last modified: 10-08-2018, 10:34 AM by travdog95. Edit Reason: Formatting )

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>
Reply
#6

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/i...oting.html
Reply
#7

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>
Reply
#8

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>
Reply
#9

Thanks @jreklund and @snelledre. I'll give those a try later today. Any thoughts on my URI Segment issue?
Reply
#10

appendQueryString="true" in my web.config should solve that one.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB