2017-05-26 68 views
1

我檢查或下載文件之前寫了重定向規則到我的登錄頁面參數(可選):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失敗。

如何允許參數?在規則

回答

1

使用QSA標誌,讓原來的查詢字符串您的網址被保留:

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] 
+1

謝謝.....! – csotelo