Basic 認証中のページでのOGPのテスト

# Basic 認証 の基本設定
AuthUserFile /path/to/.htaccess
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user

Satisfy Any
Order Allow,Deny

# FB のクローラを許可
SetEnvIf User-Agent "^facebookexternalhit.*$" fb_crawler
SetEnvIf User-Agent "^facebookplatform.*$" fb_crawler
Allow from env=fb_crawler

参考

Basic 認証中のページで OGP のテストをする

ルートのindexページのみを/sp/にリダイレクト

htaccessによるPC・スマートフォンの振り分け転送はこちらのページが明るい。
http://html-five.jp/195/

しかしながら、
ルートのindexページや、特定のページだけを/sp/にリダイレクトする方法は掲載されてなかったので、メモ。

RewriteEngine on

RewriteCond %{REQUEST_URI} !/sp/
RewriteCond %{HTTP_USER_AGENT} (iPod|iPhone|iPad|Android|Windows\ Phone)
RewriteRule ^$ /sp/ [R]

RewriteCond %{REQUEST_URI} !/sp/
RewriteCond %{HTTP_USER_AGENT} (iPod|iPhone|iPad|Android|Windows\ Phone)
RewriteRule ^example/$ /sp/example/ [R]
RewriteBase /

RewriteCond %{REQUEST_URI} /sp/
RewriteCond %{HTTP_USER_AGENT} !(iPod|iPhone|iPad|Android|Windows\ Phone)
RewriteRule ^sp/(.*)$ $1 [R]
RewriteBase /

フルパスの探し方

htaccessでよく使う、フルパスの探し方。

phpinfo作って

<?
phpinfo();
?>

以下の文字列を検索!!

DOCUMENT_ROOT

htaccessはこれで作れる。
http://www.htaccesseditor.com/#a_basic

FBのクローラを許可したげる設定はこれ。

# FBクローラーを許可する
SetEnvIf User-Agent &quot;^facebookexternalhit.*$&quot; fb_crawler
Allow from env=fb_crawler

http://www.tam-tam.co.jp/tipsnote/program/post117.html

htaccessでSSL対応

ファイル数少ない場合(SSL領域がディレクトリで分かれていない場合)

RewriteEngine on

RewriteCond %{REQUEST_URI} .*/form.php$ [OR]
RewriteCond %{REQUEST_URI} .*/confirm.php$ [OR]
RewriteCond %{REQUEST_URI} .*/comp.php$
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteCond %{REQUEST_URI} .*/index.html$ [OR]
RewriteCond %{REQUEST_URI} .*/index02.html$ [OR]
RewriteCond %{REQUEST_URI} .*/index03.html$
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R,L]

参考にしたページ
http://www.meibinlab.jp/nishijima/archives/54