htaccess的< filesMatch>只有当主机名匹配?

编程入门 行业动态 更新时间:2024-10-28 22:24:21
本文介绍了htaccess的< filesMatch>只有当主机名匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我刚刚设置好的一个地方environament具有相同的code,我不得不在生产environament成一个无业游民的虚拟机ubuntu32,

I just setted up a local environament with same code that I had in production environament into a vagrant virtual machine with ubuntu32,

的事情是,我得到了内部服务器错误与我的所有规则的的.htaccess 文件

The thing is that I got Internal Server Error with all my rules in the .htaccess file

于是,我开始去除code分离块,这是麻烦的:

So I started removing separated blocks of code and this was the trouble:

# 1 weeks <FilesMatch "\.(js|css)$"> Header set Cache-Control "max-age=604800, public" </FilesMatch> # 1 weeks <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=604800, public" </FilesMatch> # 1 MIN <FilesMatch "\.(html|htm|php)$"> Header set Cache-Control "max-age=60, private, proxy-revalidate" </FilesMatch>

的事情是,我想用完全相同的code所有environaments,是有办法,我只能包括&LT的该块; filesMatch&GT; 如果已经在本地主机?

The thing is that I would like to use the exact same code for all environaments, is there a way I can only include that block of <filesMatch> only if not in localhost?

我发现这个回答但它只是指一个页面,而不是主机名称。

I found this answer but it just refers to a page, not the host name.

推荐答案

您也许可以做:

SetEnvIf Host ^ NON_LOCAL SetEnvIf Host localhost !NON_LOCAL <FilesMatch "\.(js|css)$"> Header set Cache-Control "max-age=604800, public" env=NON_LOCAL </FilesMatch> # 1 weeks <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=604800, public" env=NON_LOCAL </FilesMatch> # 1 MIN <FilesMatch "\.(html|htm|php)$"> Header set Cache-Control "max-age=60, private, proxy-revalidate" env=NON_LOCAL </FilesMatch>

更多推荐

htaccess的&LT; filesMatch&GT;只有当主机名匹配?

本文发布于:2023-10-31 11:47:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545993.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主机名   LT   htaccess   GT   filesMatch

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!