htaccess 为单个文件设置 mimetype [英] htaccess setting the mimetype for a single file

查看:28
本文介绍了htaccess 为单个文件设置 mimetype的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 .htaccess 文件中,可以为给定的扩展名设置 mimetype,例如:

In an .htaccess file one might set the mimetype for a given extension like:

AddType application/javascript .js

如何为单个文件而不是扩展名设置 mimetype?我有一个 Javascript 需要与同一文件夹中的其他 Javascript 文件不同的 mimetype.

How would one set the mimetype for a single file instead of an extension? I have one Javascript that needs a different mimetype than other Javascript files in the same folder.

AddType application/javascript .js
AddType application/ecmascript specialfile.js

第二行不起作用.

推荐答案

在为文件添加类型之前,您可以使用 容器来匹配文件名:

You can use the <files> container to match the file's name before adding a type for it:

<Files specialfile.js>
    AddType application/ecmascript .js
</Files>

这篇关于htaccess 为单个文件设置 mimetype的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆