リダイレクトの方法一覧

HTML

<meta http-equiv="refresh" content="0; URL='http://example.com'" />

javascript

window.location.href = "http://example.com";

.htaccess

方法1

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

方法2

Redirect 301 / http://example.com

php

header("HTTP/1.1 301 Moved Permanently");//301 の場合
header('Location: http://exapmle.com/');
exit();

perl

print "Location: http://www.futomi.com/\n\n";

 

HTTP ステータス 301 302 の違い

301: 恒久的な移転

302: 一時的な移転

その他のHTTPコード
https://ja.wikipedia.org/wiki/HTTP%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82%B9%E3%82%B3%E3%83%BC%E3%83%89#3xx_Redirection_.E3.83.AA.E3.83.80.E3.82.A4.E3.83.AC.E3.82.AF.E3.82.B7.E3.83.A7.E3.83.B3