DokuWikiで情報発信

個人での情報発信や社内での情報共有に便利なDokuWikiを紹介するサイトです。

ユーザ用ツール

サイト用ツール


サイドバー

目次

DokuWikiを理解

DokuWikiの構築

よく確認するページ

Action disabled: source
· 最終更新: 2017/09/23 by oreda admin



「設定」に戻る

Apacheの.htaccessでできるアクセス制御

目的

そもそも公開ディレクトリに公開しないファイルは置かないことが前提です。
不要なファイルを置いている場合は削除しましょう。
それでも置かなければならない場合は、アクセス制御をしっかりする必要があります。

公開ディレクトリのアクセス制御のの方法として、.htaccessを利用します。


設定内容

一覧を表示させない

ディレクトリにアクセスした際に存在するファイルの一覧表示されると、見られたくないファイルも分かってしまうのでこの設定をします。

Options -Indexes

#-Indexesができない場合
IndexIgnore *


ディレクトリ以下をHTTPでアクセス禁止

Deny from all


アクセスされたくないファイルのアクセス制御

<Files ~ "^\.ht">
deny from all
</Files>
<Files ~ "^([\._]ht|README$|VERSION$|COPYING$)">
    Order allow,deny
    Deny from all
</Files>


Basic認証でアクセス制限

AuthType Basic
AuthUserFile /home/user01/XXXX/passwd
AuthName secretpage
require valid-user


特定のドメインだけ許可

特定のドメインの時だけアクセス許可し、違うドメインの場合はアクセス拒否する。

例えば、example.comならOKとし、example2.comならアクセス禁止にする

SetEnvIf Host "^example\.com$" hos_ok
order deny,allow
deny from all
allow from env=hos_ok


例:共有サーバの例

/home/user01/www/
              .htaccess         (1)公開ディレクトリ全体の制御

              example1/
                 .htaccess      (2)example1の制御(例えばBasic認証設定、特定のドメインの時だけ許可)
                 dokuwiki/
                    .htaccess   (3)dokuwiki用
                 backup/
                    .htaccess   (4)backupディレクトリ用

              example2
                 .htaccess      (2')example2の制御
                 dokuwiki/
                    .htaccess   (3')dokuwiki用
                 backup/
                    .htaccess   (4')backupディレクトリ用

(1)公開ディレクトリ全体の制御

#Options -Indexes
IndexIgnore *

<Files ~ "^\.ht">
deny from all
</Files>

(2)example1の制御

#Basic認証をする
AuthType Basic
AuthUserFile /home/user01/XXXX/passwd
AuthName secretpage
require valid-user

#example1.comの時だけ許可
SetEnvIf Host "^example1\.com$" hos_ok
order deny,allow
deny from all
allow from env=hos_ok

(3)dokuwiki用

<Files ~ "^([\._]ht|README$|VERSION$|COPYING$)">
    Order allow,deny
    Deny from all
</Files>

## Uncomment these rules if you want to have nice URLs using
## $conf['userewrite'] = 1 - not needed for rewrite mode 2
RewriteEngine on

RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L]
RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1  [QSA,L]
RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2  [QSA,L]
RewriteRule ^$                        doku.php  [L]
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteCond %{REQUEST_FILENAME}       !-d
RewriteRule (.*)                      doku.php?id=$1  [QSA,L]
RewriteRule ^index.php$               doku.php

(4)backupディレクトリ用

このバックアップ用のディレクトリはHTTPアクセスを禁止する

Deny from all





「設定」に戻る




· 最終更新: 2017/09/23 by oreda admin

ページ用ツール