LoginSignup
4
4

More than 5 years have passed since last update.

.htaccessの設定メモ

Last updated at Posted at 2016-06-13

ubuntu14.04 さくらサーバーでのhtaccess設定メモ 備忘録。

.htaccessを作成

アクセス制限をかけたいディレクトリに移動

vim .htaccess

以下を記述

AuthType Basic
AuthName "Input your ID and Password."
AuthUserFile /home/ubuntu/.htpasswd "#.htpasswdを好きな場所に置き指定"
require valid-user

.htpasswdを作成

以下のようなhtpasswd作成ツールを使用すると楽

.htpasswdファイル生成(作成)

http://www.luft.co.jp/cgi/htpasswd.php

Screen Shot 2016-06-13 at 10.23.08 AM.png

Screen Shot 2016-06-13 at 10.23.16 AM.png

.htpasswdの部分をコピーする。

先ほど指定したhtpasswdを設置するディレクトリに移動し

vim .htpasswd

コピーしたパスワードをペースト

test:t7m7HYtyrrr/g

VirtualHostの設定

AllowOverride をAllに設定する

<Directory /var/www/html/>
        AllowOverride All
</Directory>

Apacheを再起動

/etc/init.d/apache2 restart

動作確認できた。

Screen_Shot_2016-06-13_at_10_29_33_AM.jpg

IP制限の掛け方

.htaccessに以下を追記する。

order deny,allow
deny from all          #全てのホストを拒否する
allow from 許可したいIP1  #許可するホストだけ指定
allow from 許可したいIP2  #追加する分は追記

以上。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4