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

.htaccess htaccess:重写规则以允许某些文件类型具有参数(可选),.htaccess,mod-rewrite,parameters,.htaccess,Mod Rewrite,Parameters,我编写了一条规则,在检查或下载文件之前重定向到我的登录页面: 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] 如果我访问,则工作正常,但(防止缓存浏览器) 如果我访问失败 如何允

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

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
标志允许保留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]