Search code examples
iis-7asp-classiccustom-error-pages

Custom 404 not found page in iis 7 for Classic ASP


I installed windows 2008 server integrated iis 7.0

1 day ago, i use windows 2003 and iis 6.0

with windows 2008 server, everything is alright except one thing.

in 2003-iis6 i could use custom 404 pages to handle for url friendly sites. example i could set custom404.asp as custom 404 pages(execute url)

in 2008, i can't do it. when i set custom 404 page as /custom404.asp, nothing happens. in custom error pages it says this is for asp.net

how can i do it?


Solution

  • the webconfig file below fixed the problem. i share in case anyone needs

    save the code as web.config and move it to main site folder

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <httpErrors>
                <remove statusCode="404" subStatusCode="-1" />
                <error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/default.asp" responseMode="ExecuteURL" />
            </httpErrors>
         <rewrite>
            <rules>
                <rule name="MyURLCleaned" enabled="false" stopProcessing="true">
                    <match url="^([^])+" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" />
    
                    </conditions>
                    <action type="Rewrite" url="/default.asp?{R:0}" />
                </rule>
            </rules>
                <rewriteMaps>
                    <rewriteMap name="static">
                    </rewriteMap>
                </rewriteMaps>
        </rewrite>
    
        </system.webServer>
    </configuration>