我写了一个规则,在检查或下载文件之前重定向到我的登录页面:
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https://mi.domain/*.$ [NC]
RewriteRule ^.*\.(pdf|ppt|pptx|htm|html|rar|zip|gz|tar|tif|txt)$ /security.php?file=$1 [NC]
如果我访问https://mi.domain/omg.pdf有效,但是(为了防止缓存浏览器)如果我访问https://mi.domain/omg.pdf?v=1234失败。
如何允许参数?
QSA
在规则中使用标志以允许保留 URL 中的原始查询字符串:
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https://mi.domain/*.$ [NC]
RewriteRule ^.*\.(pdf|ppt|pptx|htm|html|rar|zip|gz|tar|tif|txt)$ /security.php?file=$1 [NC,QSA,L]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句