phpを用いたリダイレクト

WPなどphpファイル個別でリダイレクトが必要な場合、また.htaccessでのリダイレクトが効かない場合などに用いる。
■リダイレクト
<?php // Googleにリダイレクト(移動) header( "Location: https://google.com/" ) ; // 終了 exit ;
■301リダイレクト
// ステータスコードの301を出力する header( "HTTP/1.1 301 Moved Permanently" ) ; // 新しいページにリダイレクトを実行(移動) header( "Location: https://example.com/new.html" ) ; // 終了 exit ;
参考サイト
-
前の記事
検索結果ページ構築ベース 2016.12.08
-
次の記事
.htaccessでリダイレクト処理を記述する際にわかりやすいサイトまとめ 2016.12.14