PHP and Custom Error Pages
When deploying PHP web applications that handle their errors with their own error pages, the existingResponse
for Custom Error Pages feature of IIS should be set to “PassThrough
” for that particular site. This greatly improves the customer experience when accessing your new application, particularly if your custom error pages are merely the defaults that come with IIS.
Custom Error Pages set to “Auto
” (the default):
Custom Error Pages set to “PassThrough
”:
This property can be set for either the site in particular or the server as a whole. To set it for the server, using appcmd.exe
(found in %windir%\system32\inetsrv
), the command is
appcmd.exe set config -section:system.webServer/httpErrors /existingResponse:"PassThrough" /commit:apphost
However, you can also do this on a per site, application, or virtual directory basis as well. Using appcmd
, use the following command:
appcmd.exe set config "Default Web Site/application" -section:system.webServer/httpErrors /existingResponse:"PassThrough"
Replace “Default Web Site/application
” with the actual path to your desired location to change.
You can also do this by editing (and creating if needed) a web.config
file in the actual folder of the location, which would look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
And voila, you’re done!