mod_rewrite

(2002年5月5日更新)

/etc/httpd/conf/httpd.confを編集しました。VirtualHostの中に下記の行を追加しました。


RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "BMChecker" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Bookmark Renewal Check Agent" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "BugWeb" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Cuam" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "DC-Sakura" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "DoCoMo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Donut" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "DreamPassport" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "FlashGet" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "GetRight" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "IEFav" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Internet Explorer" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Internet Ninja" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "InternetLinkAgent" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Iria" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Irvine" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Mac OS X" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "MSIE" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "OmniWeb" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Opera" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "RealDownload" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "SunOS" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Win 9x" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Win95" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Win98" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "WinNT" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Win2000" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Win2k" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "WinXP" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Windows 2000" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Windows 95" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Windows 98" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Windows ME" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Windows NT" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Windows XP" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "WWWC" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "WWWD" [NC]
RewriteRule !^/alert\.html(|\.[a-z]{2}) /alert.html [R]

これで独占的ソフトウェアからのアクセスはすべて/alert.htmlに転送されます。これを使えば時間帯による変化やRefererによる制限などいろいろとできそうです。

JAPACHE HTTP Server ProjectModule mod_rewrite URL Rewriting EngineA Users Guide to URL Rewriting with the Apache Webserverが参考になりました。


戻る