0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

.htaccessのメモ

Last updated at Posted at 2015-11-19

.htaccessのメモ

IP制限

ディレクトリ自体に設定(指定したIPのみ可)

`# 優先順位
Order deny,allow

すべて禁止

deny from all

指定したIPのみ許可

allow from 123.123.123.123
allow from 234.234.234.234`

ファイルごと設定(指定したIPのみ可)

<Files example.html> Order deny,allow deny from all allow from 123.123.123.123 allow from 234.234.234.234 </Files>

リダイレクト

# 開始 RewriteEngine On

指定ページにリダイレクト

`# 指定ページを除く
RewriteCond %{REQUEST_URI} !examle.html

ループ防止

RewriteCond %{REQUEST_URI} !ex_error.html

スマホ制御

RewriteCond %{HTTP_USER_AGENT} ! (iPhone|Android.*Mobile|Windows.*Phone)

エラーページへ遷移

RewriteRule ^(.*)$ html/ex_error.html [R]
RewriteBase /`

httpsにリダイレクト

# 必ずhttpsにリダイレクト RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

引越し

みそは301で永久引越し

RewriteEngine on RewriteBase / RewriteRule ^(.*)$ http://www.abc.123.jp/page/ [R=301,L] Redirect 301 / http://www.abc.456.jp/page/

ベーシック認証

.htaccessの記述

AuthUserFile /var/www/example.com/.htpasswd AuthGroupFile /dev/null AuthName "Input ID and Password." AuthType Basic require valid-user <Files ~ "^.(htpasswd|htaccess)$"> deny from all </Files>

.htpasswdの記述

example:ibWEPMMsR.AJc
ユーザー名:hash化したパスワード

参考URL:htpasswd作成

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?