appcmd.exe to add/change mime type for a subdirectory of a website
-
06-02-2021 - |
Question
I read from this link to add mime for IIS 7
appcmd set config /section:staticContent /+"[fileExtension=' .xyz ',mimeType=' application/octet-stream ']"
But if I want to apply the mime settings only to a virtual directory , how to do it ?
Thanks.
Solution
I was able to solve the same problem just now by adding my web app's "site name" as a parameter right after "config." Not sure if it's different if your virtual directory is not its own app.
appcmd set config "My Site Name" /section:staticContent /+"[fileExtension='.xyz ',mimeType='application/octet-stream ']"
OTHER TIPS
The appcmd syntax to add a mime type for a specific folder is like this
appcmd set config "Default Web Site/MyFolder" /section:staticContent /+"[fileExtension='.* ',mimeType='application/octet-stream ']"
to remove a mime type for a specific folder (/- instead of /+)
appcmd set config "Default Web Site/MyFolder" /section:staticContent /-"[fileExtension='.* ',mimeType='application/octet-stream ']"
Change "Default Web Site" to the name of your website
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow