スクリプトに奇妙なバグがあります。URL が '/' で終わる場合、ユーザーを最後に '/' のない同じ URL にリダイレクトしたいだけです。
私はこのエラーが発生します:
Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/xxx/httpdocs/series.php:1) in /home/httpd/vhosts/xxx/httpdocs/series.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/mxxx/httpdocs/series.php:1) in /home/httpd/vhosts/xxx/httpdocs/series.php on line 8
コード:
<?php
$urlLast = $_SERVER['REQUEST_URI'];
$urlLast = substr($urlLast, -1);
if (($urlLast == '/') && (!strstr($_SERVER['REQUEST_URI'], 'en-streaming')))
{
$newURL = substr($_SERVER['REQUEST_URI'],0,-1).'-en-streaming';
header("Status: 301 Moved Permanently", false, 301);
header("Location: ".$newURL."");
}