Top/Linux/Apache/モジュール/mod_rewrite/ブックマークの制限

ブックマークの制限はてなブックマーク

トップページ以外のブックマークからのアクセスはトップページにリダイレクトするというポリシーの
.htaccess です。
トップページのURL ( http://www.cubic9.com/test/rewrite/index.html )は
適宜書き換えて下さい。( ¥ や () や ? に注意)

  • .htaccess
    Options FollowSymLinks
    
    RewriteEngine on
    RewriteCond    %{HTTP_REFERER}   !^http://(www\.)?cubic9\.com/test/rewrite/.*$
    RewriteCond    %{REQUEST_URI}    !^/test/rewrite/index\.html$
    RewriteRule . http://www.cubic9.com/test/rewrite/index.html [R,L]

サンプル

サンプルページ

欠陥

  • 携帯のブラウザ
  • Norton Internet Securityを導入したPCのブラウザ

等はRefererをはかないので、トップページからどのページにアクセスしようとしても
トップページにリダイレクトされる。つまり意味無し :p

解説

RewriteCond    %{HTTP_REFERER}   !^http://(www\.)?cubic9\.com/test/rewrite/.*$

Refererが http://www.cubic9.com/test/rewrite/なんちゃら 以外のとき

RewriteCond    %{REQUEST_URI}    !^/test/rewrite/index\.html$

かつ http://www.cubic9.com/test/rewrite/index.html 以外がリクエストされたとき
(無限ループ防止)

RewriteRule . http://www.cubic9.com/test/rewrite/index.html

リクエスト先を http://www.cubic9.com/test/rewrite/index.html に書き換える。

差分 一覧