Added web.config - now my site won't load the main page

Sylvaran 6 Reputation points
2022-11-19T00:54:01.037+00:00

Hi. I have a site made in PHP. I need to disable output buffering so I can have a progress bar whilst the script works. I killed buffering in PHP, but it still was buffering when you loaded the page. After some Googling, I was told to create a web.config and place it in the folder with the script:

<?xml version="1.0" encoding="UTF-8"?>  
<configuration>  
    <system.webServer>  
        <handlers>  
            <clear />  
            <add name="php" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="D:\Utils\PHP\php-cgi.exe" resourceType="Either" requireAccess="Script" responseBufferLimit="0" />  
        </handlers>  
    </system.webServer>  
</configuration>  

I did that, and it worked perfectly. Buuuuuuut, when I went to https://www.mysite.com, I now get a 404. If I put https://www.mysite.com/index.php, it works. I tried creating a default.htm with a meta refresh pushing to index.php, but still a 404. I tried modifying the web.config as follows:

<?xml version="1.0" encoding="UTF-8"?>  
<configuration>  
    <system.webServer>  
        <defaultDocument enabled="true">  
            <files>  
                <add value="index.php" />  
            </files>  
        </defaultDocument>  
        <handlers>  
            <clear />  
            <add name="php" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="D:\Utils\PHP\php-cgi.exe" resourceType="Either" requireAccess="Script" responseBufferLimit="0" />  
        </handlers>  
    </system.webServer>  
</configuration>  

but still no dice. If I rename web.config to web.config_freaking_stop_breaking_my_site (lol), the page works fine... just with buffering.

Why is my web.config killing the loading of my site via default document?

Internet Information Services
{count} votes

1 answer

Sort by: Most helpful
  1. Sylvaran 6 Reputation points
    2022-11-21T06:03:11.49+00:00

    EDIT: Nevermind, I found the solution. I did some Googling, and found that I needed to add a handler to the web.config handler list after the php one I added:

    <add name="StaticFile" path="" verb="" type="" modules="DefaultDocumentModule,StaticFileModule,DirectoryListingModule" scriptProcessor="" resourceType="Either" requireAccess="Read" preCondition="" />

    Once I did that, loading via default document without explicitly specifying a PHP file worked fine.

    Thanks. Clearing the cache didn't do anything. I turned on detailed errors, what I get is:

    HTTP Error 404.4 - Not Found
    The resource you are looking for does not have a handler associated with it.
    (Error 0x80070002)

    The default file, index.php, definitely has a handler. I specify it right there in the web.config, and if you put /index.php manually it works. Is there a debugging way to tell what file it is trying to load when it throws the 404.4? Maybe it's not the index.php it is attempting to use.

    1 person found this answer helpful.