Search code examples
httpiisweb-config

Error 500 when setting default page in web.config


My customer has a website hosted on Aruba (Windows Host - with PHP support) and this is the content of my simple web.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.web>
    </system.web>
    <system.webServer>
        <defaultDocument enabled="true">
            <files>
                <clear />
                <add value="index.php" />
            </files>
        </defaultDocument>
        <httpErrors errorMode="Custom" existingResponse="Auto" defaultResponseMode="File" >
            <remove statusCode="404"/>
            <remove statusCode="403"/>
            <remove statusCode="500"/>
            <error statusCode="404" path="404.html"/>
            <error statusCode="403" path="403.html"/>
            <error statusCode="500" path="500.html"/>
        </httpErrors>
    </system.webServer>
</configuration>

But when I navigate to the default URL https://<mywebsite>.it/ I get an HTTP 500 error from server and it doesn't redirect me to default index.php page.

I also seached in other posts on stackoverflow, but their solutions didn't solve my problems. What am I missing?

This is a screenshot of the error. Screenshot of the error from server Thank you in advance for your time!


Solution

  • The problem was not related to web.config as I thought, but it hid a different issue. As suggested by @BradoZhang in the comments, I disabled the custom-errors mode by adding the line <customErrors mode="Off"/> in system.web section of web.config. Than I saw the real problem that it is already described and solved here on stackoverflow.

    It is very strange because the website was working properly until few days ago. I think Aruba updated their servers configuration, but this is only a hypothesis.