チェ・ゲバムラの日記

脱犬の道を目指す男のブログ

リダイレクトのやり方(.htaccess、apache、php、html)

.htaccessでリダイレクト

http://hogehoge.com/aaa にアクセスしたら、http://google.comにリダイレクト。

スラッシュのつけすぎとかに注意。

Redirect permanent /aaa http://google.com/

 

rewriteのLoadModuleがhttp.confにない場合は書いてからじゃないと動かない。

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ http://google.co.jp/$1 [R,L]

 

apacheでリダイレクト

基本はhtaccessと同じ。

 

PHPでリダイレクト

index.phpを設置して下記を記載。

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

 

 

HTMLでリダイレクト

メタタグにこうかく

<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://XXXXX" />

 

 

分かりやすそうなサイトみっけ

piro791.blog.so-net.ne.jp