Htaccessメモ
提供: 初心者エンジニアの簡易メモ
2015年5月20日 (水) 02:59時点における127.0.0.1 (トーク)による版 (ページの作成:「==.htaccessを使う== httpd.confのAllowOverrideをallに変更 AllowOverride None ↓ AllowOverride all ==あるドメインのみ弾く403== Order allow,deny All...」)
目次
.htaccessを使う
httpd.confのAllowOverrideをallに変更
AllowOverride None ↓ AllowOverride all
あるドメインのみ弾く403
Order allow,deny Allow from all Deny from localhost
だめなら<Files>で囲む
<Files *> Order allow,deny Allow from all Deny from localhost </Files>
あるIPのみ許可
order deny,allow deny from all allow from 192.168.11.2 allow from 127.0.0.1 allow from 192.168.196.0/24
404のとき専用404ページを飛ばす
ErrorDocument 404 http://localhost/404.html
basic認証
<Directory "/var/www/html">
Satisfy Any
AuthType Basic
AuthName "Please enter your ID and password"
AuthUserFile /home/user1/.htpasswd
Require valid-user
Order deny,allow
deny from all
</Directory>
.htaccessでmod_rewriteを使う
Options FollowSymLinks Includes RewriteEngine on RewriteRule a.jpg$ http://localhost/ [R=301,L]
htpasswd作成
htpasswd -cb .htpasswd1 user1 pass1
