トップページ >  .htaccessを使おう!!  > サイト閲覧の制限

■ サイト閲覧の制限

 

サイトの閲覧制限


order deny,allow
deny from all
allow from 127.0.0.1/1

サイトの閲覧できるIPアドレス帯域を制限することができます。
例えば携帯以外からの閲覧を拒否する場合などに重宝します。

deny from allですべてのアクセスを拒否した後、
allow from ***.***.***.***/**で一部のアドレス帯域を許可します。

下記が3キャリアのIPアドレス帯域になります。
DoCoMo
AU
SoftBank

IPアドレスはたまに追加されるので、たまには確認して追加していかないと、
サイトを閲覧できない時があるので注意です。

■サンプル
以下は2007年2月09日現在のソースになります。

携帯端末からのみ閲覧を許可しています。
403ErrorDocumentと組み合わせれば、PCでの閲覧用のページを表示させることができます。
間違っても、403エラー用のページと.htaccessを同じ階層に置かないでください!!
PCで閲覧しようとしたとき、
403エラー用のページも閲覧制限が適用されて永久ループに陥ります。
(管理人はやってしまいましたw)
403エラー用のページは下記の.htaccessの適用範囲外に設置しましょう。

order deny,allow
deny from all
allow from 210.169.40.0/24
allow from 210.196.3.192/26
allow from 210.196.5.192/26
allow from 210.230.128.0/24
allow from 210.230.141.192/26
allow from 210.234.105.32/29
allow from 210.234.108.64/26
allow from 210.251.1.192/26
allow from 210.251.2.0/27
allow from 211.5.1.0/24
allow from 211.5.2.128/25
allow from 211.5.7.0/24
allow from 218.222.1.0/24
allow from 61.117.0.0/24
allow from 61.117.1.0/24
allow from 61.117.2.0/26
allow from 61.117.3.0/24
allow from 219.108.158.0/26
allow from 219.125.148.0/24
allow from 222.5.63.0/24
allow from 222.7.56.0/24
allow from 222.5.62.128/25
allow from 222.7.57.0/24
allow from 210.153.84.0/24
allow from 210.136.161.0/24
allow from 210.153.86.0/24
allow from 210.153.87.0/24
allow from 202.179.204.0/24
allow from 210.146.7.192/26
allow from 210.146.60.192/26
allow from 210.151.9.128/26
allow from 210.169.176.0/24
allow from 210.175.1.128/25
allow from 210.228.189.0/24
allow from 211.8.159.128/25

ErrorDocument 403 403.html

http://mobatuku.com/035/030/sample/sample.htmlにアクセスしますが、
PCからは見れません。
403エラーページへジャンプします。
携帯でも確認してみるといいですね。

■サンプルリンク
sample.html