【问题标题】:How to grant exception to Content-Disposition attachment?如何授予 Content-Disposition 附件例外?
【发布时间】:2015-10-28 07:02:48
【问题描述】:

我在 .htaccess 中使用了这段代码来强制下载所有文件 --

ForceType application/octet-stream
Header set Content-Disposition attachment

但是,我怎样才能授予 index.php 一个例外以使其不下载。我知道可以使用 FilesMatch,但我需要下载除 index.php 之外的所有文件。我无法列出 FilesMatch 中的所有文件扩展名。提前致谢!

【问题讨论】:

    标签: .htaccess content-disposition


    【解决方案1】:

    是的,你可以在FilesMatch指令中取反:

    <FilesMatch "(?!index\.php).*">
        ForceType application/octet-stream
        Header set Content-Disposition attachment
    </FilesMatch>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-19
      • 1970-01-01
      • 2016-12-18
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 2017-08-08
      相关资源
      最近更新 更多