<?php
header("Location:http://www.example.com");
header("Location:http://example.net");
?>
when I run this code, it is being redirected to example.net
why is it being redirected to example.net whereas example.com comes before example.net?
<?php
header("Location:http://www.example.com");
header("Location:http://example.net");
?>
when I run this code, it is being redirected to example.net
why is it being redirected to example.net whereas example.com comes before example.net?
收起
That's because your second header
replaces the first, because you are not using the optional replace
parameter to header
. From the manual:
replace
The optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type. By default it will replace, but if you pass in FALSE as the second argument you can force multiple headers of the same type
报告相同问题?