URLクエリを判定する方法
URLクエリがdownload=true
ならば、画像ファイルをダウンロードさせる設定を行った。(Apache2.2)
httpd.conf
RewriteEngine on
RewriteCond %{QUERY_STRING} (^|&)download=true(&|$)
# 環境変数"X_ACCESS_DEVICE"にNULLを設定
RewriteRule .* - [E=X_ACCESS_DEVICE:NULL]
Header set Content-Disposition attachment; env=DOWNLOAD
- Apache2.4だと
<If>
ディレクティブで、簡単に判定できるらしい。なんでApache2.4をインストールしなかったんだろう。
https://mariobrandt.de/archives/apache/apache-2-4-disallow-access-to-a-certain-location-if-a-query-string-is-set-952/
httpd.conf
<If "%{QUERY_STRING} =~ /action=login/">
Require ip 192.168.178.100
</If>
- RewriteCond, RewriteRuleの使い方が難しいなあ。。。
RewriteRuleの使い方
http://oxynotes.com/?p=7392
https://httpd.apache.org/docs/current/rewrite/flags.html