Htaccessメモ
提供: 初心者エンジニアの簡易メモ
目次
.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
特定UserAgent と IPアドレス( & プロキシ経由IP)を許可するように
Order deny,allow Deny from all SetEnvIf User-Agent "iPhone" allowsystem SetEnvIf User-Agent "iPod" allowsystem SetEnvIf User-Agent "ELB-HealthChecker" allowsystem SetEnvIf X-Forwarded-For "127.0.0.1" allowsystem Allow from env=allowsystem Allow from 127.0.0.1
404のとき専用404ページを飛ばす
ErrorDocument 404 ttp://localhost/404.html
ttpはhttpへ
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
