phpで301リダイレクト
<?php
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: https://blog.tama-tama.net/" );
exit();
使用例
<?php
$now = new DateTimeImmutable();
$yy = $now->format("Y"); //今年
if($q===""){
if(isset($_SERVER['HTTPS'])){
$urls1 .= 'https://';
}else{
$urls1 .= 'http://';
}
$urls1 .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];//ホストとURLを取得して今年のブログ一覧に飛ばす
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: {$urls1}/{$yy}/" );
exit();
}
コメント