リモートホスト/IPアドレスでのアクセス制限

2007年8月14日 23:59 リモートホスト/IPアドレスでのアクセス制限

忙しいので今回も旧サイトからの転載です。すんません。


ちょうど良い機会なので(謎)。.htaccessシリーズ第二弾。

.htaccessに下記のように記述することで、特定のホスト及びIPアドレスに対してアクセス制限をかけることができます。

order allow,deny
allow from all
deny from aaa.bbb.ne.jp
deny from ccc.ddd.co.jp

これでaaa.bbb.ne.jpccc.ddd.co.jpというホストからのアクセスを制限することができます。
allow: アクセスを許可するホスト/IP
deny: アクセスを拒否するホスト/IP
です。
上記の場合は、「基本的に全部のアクセスを許可するけどaaa.bbb.ne.jpccc.ddd.co.jpからはアクセスしちゃ駄目」という意味になります。

逆に、特定のホスト/IPからのみアクセスを許可したい場合は、

order deny,allow
deny from all
allow from aaa.bbb.ne.jp

となります。
これは、「基本的に全部のアクセスを拒否するけどaaa.bbb.ne.jpからはアクセスしてOK」という意味になります。
自分専用のWebアプリケーションの管理ツール等を設置するディレクトリに設定しておくと良いですね。
もちろん、外出先等からその管理ツールにアクセスできなくなるという難点もあります。
他には、携帯専用サイトでDoCoMoやau、vodafoneのホストからのみ受け付けるよう設定する、とか。

allow及びdenyに指定できるホスト名は、後方一致でワイルドカード的に指定することができます。
aaa1.bbb.ne.jpやaaa2.bbb.ne.jp、aaa3.bbb.ne.jp等を一括でアクセス制限したい場合は

order allow,deny
allow from all
deny from .bbb.ne.jp

とすれば、ホストの末尾が.bbb.ne.jpからのアクセスを全て拒否できます。
ただし、この使い方は無関係な人までアクセス拒否してしまう可能性が非常に高いので、設定する場合はその辺を考慮に入れる必要があります。

allow及びdenyには、ホスト名だけでなくIPアドレスも指定できます。
IPアドレスをワイルドカード的に指定する場合は前方一致です。また、サブネットマスクによる範囲指定も可能です。

order allow,deny
allow from all
deny from 192.168.0.1
deny from 192.168.1.
deny from 192.168.2.0/255.255.255.0
deny from 192.168.3.0/16

こんな感じで。

「アクセス制限をかける」という行為自体が私はあまり好きではないのですが、誰でもデータベース内の情報を編集できる、所謂wikiのような「性善説系」サイトを長年やってると、やはり必要悪だなと特に改めて思わされますね。

阿部辰也へのお仕事のご依頼・お問合せはこちら

Twitter始めました。Followはお気軽にどうぞ。

関連するブログ記事
スポンサード リンク
カテゴリー
.htaccess
タグ
.htaccess | アクセス制限
現在位置
TOP > Web制作技術 > .htaccess > リモートホスト/IPアドレスでのアクセス制限
前のブログ記事
同人ゲーム『ひぐらしのなく頃に』が実写映画化だってさ [2007年8月13日 23:59]
次のブログ記事
ケータイメールで鬼ごっこ [2007年8月15日 23:59]

トラックバック(0)

このブログ記事に対するトラックバックURL:

コメント(9)

payday loans [2014年5月12日 21:14]

qjcjozfs http://paydayloansnsa.com/ payday loans

Coach Handbags Clearance [2014年9月27日 06:07]

coach bags
Coach Handbags Clearance http://www.hardpresseditions.com/coach1.html

payday loans [2014年10月18日 07:48]

uetidiv http://paydayloanshst.com/ payday loans

hello [2015年3月22日 11:02]

sgmoxqma [url=http://sdfxyc.com/]ltwhgpes[/url]

oijlee [2017年1月16日 13:10]

Blood pressure is determined, jiffy close to second, close the deliberate between heart efficiency versus overall circumferential defences underground and varies depending on berth, emotional regal, interest, and relative health/disease states. viagra without a doctor prescription is regulated close the brain via both the perturbed and endocrine systems.

Ilymhnv [2017年1月17日 07:22]

As you can go through from the blood sway chart, simply one of the numbers has to be higher viagra without a doctor prescription or modulate than it should be to number as either high blood bring pressure to bear on or debilitated blood crushing:

viagra without a doctor prescription [2017年1月19日 03:24]

The best evidence indicates that enormous blood albatross does not cause headaches or nosebleeds, except in the turn out that in the event of of hypertensive moment, a medical emergency when blood difficulties is 180/110 mm Hg or higher. If your blood pressure is unusually high viagra without a doctor prescription you have headache or nosebleed and are feeling unwell, wait five minutes and retest. If your reading remains at 180/110 mm Hg or higher, call 9-1-1.

aty34t [2017年1月22日 04:48]

The nicest demonstration indicates that high blood insistence does not justification headaches or nosebleeds, except in the box of hypertensive turning-point, a medical emergency when blood burden is 180/110 mm Hg or higher. If your blood compel is unusually weighty viagra without a doctor prescription you accept problem or nosebleed and are feeling unwell, pause five minutes and retest. If your reading remains at 180/110 mm Hg or higher, call 9-1-1.

gmxctb [2017年1月28日 04:38]

The rout attest indicates that merry blood insistence does not justification headaches or nosebleeds, except in the case of hypertensive catastrophe, a medical exigency when blood tension is 180/110 mm Hg or higher. If your blood pressure is unusually weighty viagra without a doctor prescription you have problem or nosebleed and are feeling unwell, wait five minutes and retest. If your reading remains at 180/110 mm Hg or higher, christen 9-1-1.

コメントする


画像の中に見える文字を入力してください。

 

このブログについて

阿部辰也

Webコンサルタントやシステムエンジニア、執筆業などをやっている、グッドホープ代表・阿部辰也のブログです。
Web技術系のTipsから仕事の話、趣味の話まで色々と。
人生は所詮生まれてから死ぬまでの壮大な暇つぶし。
だったら有意義に暇をつぶして生きましょー。

阿部辰也へのお仕事のご依頼・問合せはこちらからどうぞ。

Twitter: @t_abe
読書メーター: ID:Tatsuya

このブログのサイトマップ
このブログのはてなブックマーク数

Feed/RSS購読

タグクラウド

最近のトラックバック

阿部辰也の著書

77のキーワードで知る インターネットで稼ぐ 図解 ブログ・メルマガ・Webサイト構築の基本

77のキーワードで知る インターネットで稼ぐ 図解 ブログ・メルマガ・Webサイト構築の基本

頑張って書いたのに、出版後すぐに出版社が倒産して印税も貰えずじまいで俺涙目(笑)。

Powered by Movable Type 5.02

スポンサード リンク

はてなブックマーク



あわせて読みたい

t-abeの今読んでる本

t-abeの最近読んだ本

t-abeの今やってるゲーム

t-abeの最近やったゲーム