【问题标题】:How to add .htaccess file to my Visual Studio solutions如何将 .htaccess 文件添加到我的 Visual Studio 解决方案
【发布时间】:2015-07-22 05:09:15
【问题描述】:

我需要添加 Expires 标头 - 在谷歌搜索时,我从 link 得到了解决方案。但是这个文件在哪里?是否可以将其添加到我的 Visual Studio 解决方案中?是否需要在母版页中引用此类文件?

【问题讨论】:

  • 您确定您的站点部署在 Apache 服务器上吗?对于使用 Apache(即在 LAMP 堆栈上)的人来说,使用 Visual Studio 并不是很常见...
  • 您确定需要 .htaccess 吗?据我所知,将它与 IIS 一起使用是没有意义的(您可以搜索 bing.com/search?q=iis+htaccess )...如果您只想寻找过期标题,那么您的帖子就是许多帖子之一的简单副本,例如 stackoverflow.com/questions/10825497/…跨度>
  • 澄清一下:IIS 不支持 .htaccess 原样 - 您需要改用 web.config,但我不确定它是否支持 Expires 标头。

标签: c# asp.net vb.net .htaccess visual-studio-2012


【解决方案1】:

如果您想在带有 ASP.NET 的 IIS 中为静态内容设置 Expires 标头,您需要在 web.config 中进行。不久前我在博客上写过这个here。

但这里是为您的 web.config 的 <system.webServer> 节点添加默认 7 天到期的代码。

<staticContent>
 <clientCache cacheControlMaxAge="7.00:00:00" cacheControlMode="UseMaxAge" />
</staticContent>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-09
    • 2015-04-06
    • 1970-01-01
    • 2017-07-11
    • 2015-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多