下载xml文件后重定向[重复]

This question already has an answer here:

I use the following code to download an xml file

<?php
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="download.xml"');
echo simplexml_load_file('temp.xml');
unlink('temp.xml');
?>

I would like to redirect to index.php after this. How do I do this?

header('location...) and meta refresh do not work

</div>

Well because you send the header and content this can't be done.

You have to redirect first and then let the file download on the target site.

Make your website change the url two times with javascript:

<script>
  location.href="your_php_file_that_downloads_xml.php";
  location.href="/other/site";
</script>