Custom Error Handling

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-04-19T03:14:08Z Indexed on 2010/04/19 4:03 UTC
Read the original article Hit count: 490

Using GoDaddy to host my site (I know that's my first problem)! :-)

Trying to setup customer error messages for my site using IIS7. GoDaddy allows you to setup a 404 in their control panel, but I can't override this, or setup any additional error redirects, specifically a 500-server error.

Here is my web.config file:

<configuration>
   <system.webServer>
      <rewrite>
         <rules>
            <rule name="Redirect to WWW" stopProcessing="true">
            <match url=".*" />
             <conditions>
               <add input="{HTTP_HOST}" pattern="^mysite.com$" />
             </conditions>
            <action type="Redirect" url="http://www.mysite.com/{R:0}" redirectType="Permanent" /> 
               </rule>
        </rules>
       </rewrite>
    </system.webServer>

    <system.web>
      <customErrors mode="On" defaultRedirect="http://www.mysite.com/oops.php">    
        <error statusCode="404" redirect="http://www.mysite.com/oops.php?error=404" />
        <error statusCode="500" redirect="http://www.mysite.com/oops.php?error=500" />
      </customErrors>
     </system.web>
</configuration>

© Stack Overflow or respective owner

Custom Error Handling

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-04-19T14:09:26Z Indexed on 2010/04/19 14:13 UTC
Read the original article Hit count: 490

Using GoDaddy to host my site (I know that's my first problem)! :-)

Trying to setup custom error messages for my site using IIS7. GoDaddy allows you to setup a 404 in their control panel, but I can't override this, or setup any additional error redirects, specifically a 500-server error.

Here is my web.config file:

<configuration>
   <system.webServer>
      <rewrite>
         <rules>
            <rule name="Redirect to WWW" stopProcessing="true">
            <match url=".*" />
             <conditions>
               <add input="{HTTP_HOST}" pattern="^mysite.com$" />
             </conditions>
            <action type="Redirect" url="http://www.mysite.com/{R:0}" redirectType="Permanent" /> 
               </rule>
        </rules>
       </rewrite>
    </system.webServer>

    <system.web>
      <customErrors mode="On" defaultRedirect="http://www.mysite.com/oops.php">    
        <error statusCode="404" redirect="http://www.mysite.com/oops.php?error=404" />
        <error statusCode="500" redirect="http://www.mysite.com/oops.php?error=500" />
      </customErrors>
     </system.web>
</configuration>

© Stack Overflow or respective owner

Related posts about iis7

Related posts about error-handling