我有这个代码:
<?php
//Search logic for Holiday.GE
$search_variables = $_GET['s']. '+' .$_GET['cat'];
$var_lang_now = $_GET['lang_current_search'];
if ($var_lang_now == ru OR $var_lang_now == en) {
$refering_page = 'http://dev.holiday.ge/' . $var_lang_now . "/";
} else {
$refering_page = 'http://dev.holiday.ge';
}
//This sends http post to url without curl
header("Status: 301 Moved Permanently");
header("Location:$refering_page?s=$search_variables");
exit;
?>
在我测试它的本地主机上运行良好。但是在实时服务器上,它会出错:
Warning: Cannot modify header information - headers already sent by (output started at /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php:3) in /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php on line 15
Warning: Cannot modify header information - headers already sent by (output started at /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php:3) in /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php on line 16
15和16是出口前的线路;
我按照答案中的建议尝试了,但我得到了同样的错误!
<?php
ob_start();
//Search logic for Holiday.GE
$search_variables = $_GET['s']. '+' .$_GET['cat'];
$var_lang_now = $_GET['lang_current_search'];
if ($var_lang_now == ru OR $var_lang_now == en) {
$refering_page = 'http://dev.holiday.ge/' . $var_lang_now . "/";
} else {
$refering_page = 'http://dev.holiday.ge';
}
//This sends http post to url without curl
header("Status: 301 Moved Permanently");
header("Location:$refering_page?s=$search_variables");
exit;
ob_end_flush();
?>