IIS server blocking access to .webp files

22.2k views Asked by At

So I'm trying to add .webp image support for a WordPress site, which is run on IIS.

Now the image exists on the server and the file name is correct but when I try to load the image via URL address in the browser I get the 404 error.

404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Anyone know how I might resolve this issue?

I tried added <add extension=".webp" policy="CacheUntilChange" kernelCachePolicy="DontCache" /> but this doesn't work as it's to do with caching.

Is there somewhere were I can allow access to certain file types?

Do I maybe need to allow the filetype through the firewall?

I'm still new to working with IIS so I'm a little lost.

Cheers

4

There are 4 answers

1
Web Dev Guy On BEST ANSWER

Ok figured it out.

I had to allow the mime type in iis manager.

https://technet.microsoft.com/en-us/library/cc725608(v=ws.10).aspx

File name extension: ".webp"; MIME type: "image/webp".

See https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types#webp_image

1
Mahnian On

You'll need to add this config to your webconfig file:

<configuration> 
    <system.webServer> 
        <staticContent> 
            <mimeMap fileExtension=".webp" mimeType="image/webp" /> 
        </staticContent> 
    </system.webServer> 
</configuration>
1
Barat Kumar On

Webp images are not showing, when you run or debug the application. Especially in IIS Express and IIS. For IIS we can go the Mime type in the app config as mentioned. But for the IIS express, even though you add in app.config, it does not show up. Just follow this procedure to resolve this issue.

  1. Open the IIS Express Dialog using the icon from System tray. Check image. Open IIS Express from system tray

  2. In the dialog box, select the website. You can see the related details in the below section. IIS Express dialog box

  3. See the config path, it varies for every app or site you develop. Click that link and you can get the config file opened in your VS studio. Now add the webp mime extension code along with other image types. save the file and close it.

Now, you are able to view the webp images in local browsing in debug mode. Problem resolved.

2
Macster On

The fastest solution with less headache is to just add the file extension .webp to the mime types as below:

  1. Select website from IIS Manager: 1. select website from IIS Manager

  2. Add file extension to Mime Types: 2. add file extension to Mime Types File name extension: ".webp"; MIME type: "image/webp".

See https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types#webp_image