[[Cheatsheet]]
[[htaccess Cheatsheet (the jackol’s den):http://www.thejackol.com/htaccess-cheatsheet/]]
#contents
*cheatsheet for the .htaccess file [#w5f98d31]

**Enable Directory Browsing [#b260e6ff]
**ディレクトリ参照を許可[#b260e6ff]
 Options +Indexes
 ## block a few types of files from showing
 IndexIgnore *.wmv *.mp4 *.avi

**Disable Directory Browsing [#qa4b7287]
**ディレクトリ参照を不可[#qa4b7287]
 Options All -Indexes

**Customize Error Messages [#ya2814ed]
**エラーメッセージのカスタマイズ[#ya2814ed]
 ErrorDocument 403 /forbidden.html
 ErrorDocument 404 /notfound.html
 ErrorDocument 500 /servererror.html

**Get SSI working with HTML/SHTML [#yd28e3d3]
**HTML/SHTMLでのSSI動作[#yd28e3d3]
 AddType text/html .html
 AddType text/html .shtml
 AddHandler server-parsed .html
 AddHandler server-parsed .shtml
 # AddHandler server-parsed .htm

**Change Default Page (order is followed!) [#je5f8b33]
**デフォルトページの変更 [#of5b0c3c]
定義順に従う
 DirectoryIndex myhome.htm index.htm index.php

**Block Users from accessing the site [#e28b31e9]
**他サイトからのアクセスをブロック[#e28b31e9]
 <limit GET POST PUT>
 order deny,allow
 deny from 202.54.122.33
 deny from 8.70.44.53
 deny from .spammers.com
 allow from all
 </limit>

**Allow only LAN users [#f1a5b672]
**LANユーザのみ許可[#f1a5b672]
 order deny,allow
 deny from all
 allow from 192.168.0.0/24

**Redirect Visitors to New Page/Directory [#t76d68c7]
**新ページ/ディレクトリへ訪問者をリダイレクト[#t76d68c7]
 Redirect oldpage.html http://www.domainname.com/newpage.html
 Redirect /olddir http://www.domainname.com/newdir/

**Block site from specific referrers [#pf7453c8]
**特定のリファラによる他サイトからのアクセスをブロック[#pf7453c8]
 RewriteEngine on
 RewriteCond %{HTTP_REFERER} site-to-block\.com [NC]
 RewriteCond %{HTTP_REFERER} site-to-block-2\.com [NC]
 RewriteRule .* - [F]

**Block Hot Linking/Bandwidth hogging [#i46900e5]
 RewriteEngine on
 RewriteCond %{HTTP_REFERER} !^$
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
 RewriteRule \.(gif|jpg)$ - [F]

**Want to show a “Stealing is Bad” message too? [#j66dfe07]
 '''Add this below the Hot Link Blocking code:'''
 Add this below the Hot Link Blocking code:
 
 RewriteRule \.(gif|jpg)$ http://www.mydomain.com/dontsteal.gif [R,L]

**Stop .htaccess (or any other file) from being viewed [#u0e0ffd0]
**.htaccess(またはその他のファイル)を参照不可に[#u0e0ffd0]
 <files file-name>
 order allow,deny
 deny from all
 </files>

**Avoid the 500 Error [#y15a3a2f]
**500 Errorを回避 [#y15a3a2f]
 # Avoid 500 error by passing charset
 AddDefaultCharset utf-8

**Grant CGI Access in a directory [#n7f2d1c8]
**ディレクトリにCGIアクセス権を付与[#n7f2d1c8]
 Options +ExecCGI
 AddHandler cgi-script cgi pl
 # To enable all scripts in a directory use the following
 # SetHandler cgi-script

**Password Protecting Directories [#u250aa43]
 '''Use the .htaccess Password Generator and follow the brief instructions!'''
**ディレクトリをパスワードで保護[#u250aa43]
 Use the .htaccess Password Generator and follow the brief instructions!
 
**Change Script Extensions [#g9bbcdca]
**スクリプトの拡張子を変更[#g9bbcdca]
 AddType application/x-httpd-php .gne
 
 '''gne will now be treated as PHP files! Similarly, x-httpd-cgi for CGI files, etc.'''
 gne will now be treated as PHP files! Similarly, x-httpd-cgi for CGI files, etc.

**Use MD5 Digests [#td674151]
 '''Performance may take a hit but if thats not a problem, this is a nice option to turn on.'''
**MD5ダイジェストを使用[#td674151]
 Performance may take a hit but if thats not a problem, this is a nice option to turn on.
 
 ContentDigest On

**The CheckSpelling Directive [#m3ccccaa]
 '''From Jens Meiert: CheckSpelling corrects simple spelling errors (for example, if someone forgets a letter or if any character is just wrong). Just add CheckSpelling On to your htaccess file.
**ディレクティブのスペルチェック[#m3ccccaa]
 From Jens Meiert: CheckSpelling corrects simple spelling errors (for example, if someone forgets a letter or if any character is just wrong). Just add CheckSpelling On to your htaccess file.
 
 The ContentDigest Directive
 
 As the Apache core features documentation says: “This directive enables the generation of Content-MD5 headers as defined in RFC1864 respectively RFC2068. The Content-MD5 header provides an end-to-end message integrity check (MIC) of the entity-body. A proxy or client may check this header for detecting accidental modification of the entity-body in transit.
 
 Note that this can cause performance problems on your server since the message digest is computed on every request (the values are not cached). Content-MD5 is only sent for documents served by the core, and not by any module. For example, SSI documents, output from CGI scripts, and byte range responses do not have this header.”
 
 To turn this on, just add ContentDigest On.'''
 To turn this on, just add ContentDigest On.
 
**Save Bandwidth [#gdc9e39a]
**帯域を保持[#gdc9e39a]
 # Only if you use PHP
 <ifmodule mod_php4.c>
 php_value zlib.output_compression 16386
 </ifmodule>

**Turn off magic_quotes_gpc [#re9aa3ea]
**magic_quotes_gpcはoff [#re9aa3ea]
 # Only if you use PHP
 <ifmodule mod_php4.c>
 php_flag magic_quotes_gpc off
 </ifmodule>

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS