我的脚本有一个奇怪的错误,我只想重定向用户(如果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."");
}
之前有Unicode BOM<?php
吗?
当您使用“带有BOM(字节顺序标记)的UTF-8编码”保存文件时,特殊字符序列(0xEF 0xBB 0xBF)将自动插入文件的开头。
只需尝试使用“ UTF-8 WITHOUT BOM”(如果存在)保存文件,或尝试其他编辑器。
notepad.exe中的AFAIK UTF-8是“带BOM”。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句