简体   繁体   中英

appcmd.exe to add/change mime type for a subdirectory of a website

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.

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 ']"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM