Apache的个人备忘录

判断URL查询的方法

如果URL查询为download=true,则进行了使图片文件可下载的设置。(Apache2.2)

请参照网页https://serverfault.com/questions/445857/make-apache-or-iis-add-a-header-if-a-certain-query-string-is-present来添加一个标题。

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だとディレクティブで、簡単に判定できるらしい。なんでApache2.4をインストールしなかったんだろう。

 

    https://mariobrandt.de/archives/apache/apache-2-4-disallow-access-to-a-certain-location-if-a-query-string-is-set-952/
 <If "%{QUERY_STRING} =~ /action=login/">
     Require ip 192.168.178.100
 </If>
    RewriteCond, RewriteRuleの使い方が難しいなあ。。。

RewriteRule的使用方法

Apacheのmod_rewriteモジュールの使い方を徹底的に解説


https://httpd.apache.org/docs/current/rewrite/flags.html是有关重定向标志的Apache文档的链接。

bannerAds