- 追加された行はこの色です。
- 削除された行はこの色です。
- WebServer/.htaccessの利用例 へ行く。
// author:1
***.htaccessの利用例 :D
以下に設定例を書いてみました。~
ご参考下さい。 :)
(1) BASIC認証
&font(b){(1) BASIC認証};
# cat .htaccess
deny from all
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /var/www/cgi-bin/pass/.htpasswd
require valid-user
satisfy any
※.htpasswdを生成するには2とおりある
1.コマンドベースで作成する。(コンソール,telnet,ssh)
htpasswd -c /フルパス/ ユーザ名
2.PHPプログラムを利用する
(2) CGIを動作させる設定
&font(b){(2) CGIを動作させる設定};
# cat .htaccess
Addtype application/x-httpd-cgi .cgi
Options ExecCGI
(3) 拡張子によるアクセス制御の設定
Addtype application/x-httpd-cgi .cgi
&font(b){(3) 拡張子によるアクセス制御の設定};
# cat .htaccess
<Files ~ "\.(dat|log|csv)$">
(4) リダイレクト設定
deny from all
</Files>
&font(b){(4) リダイレクト設定};
(5) Directory Indexの設定
# cat .htaccess
Redirect permanent / http://www.yahoo.co.jp
(6) 特定ホスト(IPアドレス)によるアクセス制御の設定
&font(b){(5) Directory Indexの設定};
# cat .htaccess
DirectoryIndex index.html index.htm index.cgi index.php
&font(b){(6) 特定ホスト(IPアドレス)によるアクセス制御の設定};
★192.168.254.0/255.255.255.0は拒否する場合
# cat .htaccess
order allow,deny
allow from all
deny from 192.168.254.0/255.255.255.0
★192.168.254.0/255.255.255.0は許可する場合
# cat .htaccess
order deny,allow
deny from all
allow from 192.168.254.0/255.255.255.0
***.htaccessの利用例 :D
以下に設定例を書いてみました。~
ご参考下さい。 :)
(1) BASIC認証
&font(b){(1) BASIC認証};
# cat .htaccess
deny from all
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /var/www/cgi-bin/pass/.htpasswd
require valid-user
satisfy any
※.htpasswdを生成するには2とおりある
1.コマンドベースで作成する。(コンソール,telnet,ssh)
htpasswd -c /フルパス/ ユーザ名
2.PHPプログラムを利用する
(2) CGIを動作させる設定
&font(b){(2) CGIを動作させる設定};
# cat .htaccess
Addtype application/x-httpd-cgi .cgi
Options ExecCGI
(3) 拡張子によるアクセス制御の設定
Addtype application/x-httpd-cgi .cgi
&font(b){(3) 拡張子によるアクセス制御の設定};
# cat .htaccess
<Files ~ "\.(dat|log|csv)$">
(4) リダイレクト設定
deny from all
</Files>
&font(b){(4) リダイレクト設定};
(5) Directory Indexの設定
# cat .htaccess
Redirect permanent / http://www.yahoo.co.jp
(6) 特定ホスト(IPアドレス)によるアクセス制御の設定
&font(b){(5) Directory Indexの設定};
# cat .htaccess
DirectoryIndex index.html index.htm index.cgi index.php
&font(b){(6) 特定ホスト(IPアドレス)によるアクセス制御の設定};
★192.168.254.0/255.255.255.0は拒否する場合
# cat .htaccess
order allow,deny
allow from all
deny from 192.168.254.0/255.255.255.0
★192.168.254.0/255.255.255.0は許可する場合
# cat .htaccess
order deny,allow
deny from all
allow from 192.168.254.0/255.255.255.0