ファイル名は
参考に http://xn--u8jxb9ib9150b2px.jp/htaccess/referer/
*.htaccess
こちらはフォルダ内で(js|ico|gif|jpg|png|css)以外はまずindex.phpを実行する。
RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
*フォルダを鍵を掛ける
AuthType Basic AuthName “Please enter your ID and password” AuthUserFile /var/www/フォルダ名/.htpasswd AuthGroupFile /dev/null require valid-user
#指定フォルダ #RewriteBase /public_html/
#IndexないならIndex.phpをメインにする。 #DirectoryIndex index.php
#サイトマップの指定 #RewriteRule sitemap.xml sitemap.php
-d指定したディレクトリが存在すればtrue RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d
-f指定したファイルが存在すればtrue RewriteCond %{REQUEST_FILENAME} !-f
RewriteCondディレクティブでRewriteRuleの条件を設定できます。複数の条件を設定することが可能。 ※RewriteCondの前にRewrite Engine On とする必要があります。
サンプル RewriteEngine on
RewriteRule^rm_(\d+?)_.html+ index.php?rm=$1
RewriteRule^r_id_(.+?)(_)(.+?)(_).html+ m/$1/parm/$2$3$4/index.html
RewriteRule^([0-9A-Za-z]+)/([0-9A-Za-z)]+)\.html index.php?id=$1&mpc=$2 [L]
*画像をダウンロードされないようにする。 右クリック禁止のように HTMLファイルに画像ファイルへのパスが、<img src=“hoge.jpg” width=100 height=80>などとあった場合、hoge.jpgのRefererは、そのHTMLファイルになります。
SetEnvIf Referer “^http://www\.enjoy-lei\.com” ref_ok 第3者のサーバがRefererになっていれば、アクセスを拒否します。
*サイト文字コード変換
php_value default_charset UTF-8 php_value mbstring.language Japanese php_flag mbstring.encoding_translation on php_value mbstring.internal_encoding UTF-8 php_value mbstring.http_input UTF-8 php_value mbstring.http_output UTF-8 php_value mbstring.detect_order UTF-8 php_value mbstring.substitute_character UTF-8 php_value mbstring.func_overload UTF-8
*アクセスの移行
#別のサンプル RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule book([0-9a-zA-Z_\-]+).html$ http://example.com/test/index.php?bookid=$1 [L]
#解釈 #例えば、上記ルールを書いた .htaccess を test ディレクトリに置いた場合 #http://example.com/test/book123.html #にアクセスすると #http://example.com/test/index.php?bookid=123が実行される。
*セッションの維持時間の設定 php_value session.gc_maxlifetime 3600