木曜日, 11月 06, 2008

.htaccessに関する覚え書き

この覚え書き、便利です。

ディレクトリー内をブラウズ可能に

Options +Indexes
## block a few types of files from showing
IndexIgnore *.wmv *.mp4 *.avi

その逆

Options All -Indexes

エラーページの指定

ErrorDocument 403 /somePage1.html
ErrorDocument 404 /somePage2.html
ErrorDocument 500 /somePage3.html

デフォルトで表示されるページの順番を指定

DirectoryIndex myhome.htm index.htm index.php

アクセス制限

order deny,allow
deny from 123.456.789.00
deny from 123.456.789.00
deny from .someDomain.com
allow from all 
Block Visitors From Specific Referring Sites

RewriteEngine on
RewriteCond %{HTTP_REFERER} site-to-block.com [NC]
RewriteCond %{HTTP_REFERER} site-to-block-2.com [NC]
RewriteRule .* - [F]

検索ボットを拒否

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^searchbot1 [OR]
RewriteCond %{HTTP_USER_AGENT} ^searchbot2 [OR]
RewriteCond %{HTTP_USER_AGENT} ^searchbot3
RewriteRule ^(.*)$ http://www.yourSite.com/goAway.html

OR

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^searchbot1 [OR]
RewriteCond %{HTTP_USER_AGENT} ^searchbot2 [OR]
RewriteCond %{HTTP_USER_AGENT} ^searchbot3
RewriteRule ^(.*)$ http://www.someOtherWebsite.com/ [R, L] 

0 件のコメント: