Adding custom MIME types to web.config in IIS7 with Go Daddy

Standard

For a few months I’ve been having issues with certain files on my Go Daddy web host.  I would upload them and then try to access them and I would get the dreaded default “Oops! Page not found” error.

After searching the Go Daddy community forums and some Microsoft IIS sites I realized that IIS7 does not serve up files with extensions it doesn’t know what to do with.  This is done for security reasons so that people cant hit your web.config file, or maybe an access database file (.mdb).

To get around this you can add custom MIME types to the IIS 7.0 manager but what if you don’t have access to this?  For example if you are on a shared web host account with Go Daddy and all you have is FTP access and web site control panel options which are limited.

The answer is to add some code to your web.config file to allow your site to recognize these different file extensions and pass the proper information in the header to the browser.

The code is very simple, just make sure you put it in the right place or you will break your entire website.  Backup your web.config file first if you have never modified it before.

Here is some sample code for adding the file types .m4v, .ogg, .oga, .ogv, and .webm.

NOTE: When I tried to add .mp4 to my list it caused the server to return an unknown error, I suspect maybe its because Go Daddy has mp4 already included on their list (see link below) I don’t know, but regardless mp4 caused my site to crash, everything else works fine.

<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".m4v" mimeType="video/m4v" />
            <mimeMap fileExtension=".ogg" mimeType="audio/ogg" />
            <mimeMap fileExtension=".oga" mimeType="audio/ogg" />
            <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
            <mimeMap fileExtension=".webm" mimeType="video/webm"/>
        </staticContent>
    </system.webServer>
</configuration>

If you already have a web.config file you probably already have the system.webServer section. don’t add a second one just put the staticContent section inside the webServer section.

For more information see the IIS blog post and Go Daddy mime type listing url’s I found along the way.

http://blogs.iis.net/bills/archive/2008/03/25/how-to-add-mime-types-with-iis7-web-config.aspx
http://community.godaddy.com/help/article/3821

Advertisement