.htaccess - RewriteCond 获取主页的 THE_REQUEST
问题描述
我有这些指令.htaccess
不缓存某些网址的页面:
<IfModule mod_headers.c>
RewriteCond %{THE_REQUEST} (compile|chat|another-page) [NC]
RewriteRule ^ - [NC,E=HEADER_NOCACHE:true]
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</IfModule>
它就像页面的魅力一样h..ps://my-url/compile
,h..ps://my-url/chat
并且h..ps://my-url/another-page
我需要为主页添加相同的规则,应该是(我不确定/
最后是否有):
h..ps://my-url
我应该在第一个条件中添加什么?就像是?
RewriteCond %{THE_REQUEST} (compile|chat|another-page|/) [NC]
解决方案
您可以只使用一个简单的表达式块(在 Apache 2.4 或更高版本中可用):
<If "%{REQUEST_URI} =~ m#^/(compile|chat|another-page)?$#">
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</If>
推荐阅读
- java - 获取一个类的一些对象并在另一个类中使用
- python - 如何使用 gmail API 在现有线程中创建草稿消息
- android - Kotlin:EditText 没有被清除,奇怪
- batch-file - 使用批处理文件安装网络打印机
- android - 从堆栈历史记录中清除特定活动
- swift - 动态查询 Firestore 的优雅方式
- angular - 循环依赖检测到Angular 6,main.ts
- scala - 在Scala中通过反射调用方法
- c# - 过滤ICollectionView后如何选择第一项
- spring-boot - Springboot REST上下文映射——多应用