redirect 301 permanent (永久的なリダイレクト)

PHPでredirect 301 (permanent)する方法。

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.jp/");
?>

perlでredirect 301 (permanent)する方法。

#!/usr/bin/perl

use strict;
use warnings;

my $redirect_location = "http://www.example.jp/";

print <<_EOF;
Status: 301 Moved Permanently
Location: $redirect_location
Content-Type: text/html

_EOF

rubyでredirect 301 (permanent)する方法。

#!/usr/local/bin/ruby

redirect_location = "http://www.example.jp/"

puts <<_EOF
Status: 301 Moved Permanently
Location: #{redirect_location}
Content-Type: text/html

_EOF

Apacheの設定では。

Apacheの設定ではRedirectディレクティブやRewriteで。以下を参照。

http://phpspot.org/blog/archives/2006/06/301.html

redirect 301 /old/old.html http://www.example.jp/
    RewriteEngine On
    RewriteCond %{http_host} ^www.old.example.com
    RewriteRule ^(.*) http://www.new.example.jp/$1 [R=301,L]