htaccess:重写规则以允许某些带有参数的文件类型(可选)

乔特洛

我写了一个规则,在检查或下载文件之前重定向到我的登录页面:

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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章