【发布时间】:2016-05-22 22:54:24
【问题描述】:
如果 url 以 mp3?dl 结尾,我想在响应中发送 Content-disposition "attachment" 标头。
我想在.htaccess 中这样做。
我试过了:
<FilesMatch ".mp3?dl$">
Header set Content-disposition "attachment"
</FilesMatch>
有一个 WordPress 网站在 .htaccess 中添加了一些其他内容。如果我在文件末尾添加上面的这个 sn-p,它不会做任何改变。如果将其放在文件的顶部,则整个网站都会以服务器错误 (500) 结束。
要检查是否添加了标题,我使用curl:
$ curl -X HEAD -i 'http://example.com/files/audio/ping.mp3?dl'
HTTP/1.1 200 OK
Date: Sun, 22 May 2016 13:34:00 GMT
Server: Apache
Last-Modified: Sun, 22 May 2016 13:21:51 GMT
ETag: "12a...2"
Accept-Ranges: bytes
Content-Length: 76385
Content-Type: application/octet-stream
curl: (18) transfer closed with 76385 bytes remaining to read
如何在.htaccess 中执行此操作?
【问题讨论】:
标签: php wordpress apache .htaccess