When setting a Custom Error page in IIS 6 you need to watch the drop down option for File or URL. Setting as File means IIS returns the page as markup so if using a dynamic file type such as PHP or ASP this setting returns your dynamic page as if it was a plain HTML page.
To ensure the dynamic 404 error page runs set the drop down to URL which makes IIS to send a redirect to the client so the client requests the Error Page which ensures IIS runs the dynamic page before sending the output to the client.
