开发者

php redirect and ical download issues

Our application have lots of old ical links and I am trying to redirect them to the new url. I can't do a .htaccess redirect because this new url is generated using php . There fore I am using php's header function to redirect users from redirect.php to test.php . But the problem is , if user access example.com/redirect.php .. ical file gets downloaded but the url in t开发者_如何学Gohe browser remains example.com/redirect.php. It should have changed to example.com/test.php. I am using a 301 redirect.

I have tried javascript window.location.href function but the same results are coming in. I hope I have explained it properly. Thanks for the help.

First php file for example redirect.php have this code in place.

<?
header("Location: http://example.com/test.php");
?>

Second file test.php have this code to download an ical file. Code goes like this.

<?php
header("Content-Type: text/Calendar");
header("Content-Disposition: download; filename=calendar.ics");
echo "BEGIN:VCALENDAR\r\n";
//echo "X-WR-TIMEZONE:America/New_York\r\n";
echo "X-APPLE-CALENDAR-COLOR:#b91113\r\n";
echo "X-WR-CALNAME:$cal_name\r\n";
echo "VERSION:2.0\r\n";
echo "PRODID:-//Test//NONSGML Test//EN\r\n";
echo "METHOD:PUBLISH\r\n";
echo $data;?>

If I remove header code for Ical download, this redirect works. URL in the browser window changes to the new location.


You're redirect.php file should look like this:

 <?
 header("Location: http://example.com/test.php");
 exit;
 ?>

Try it out and let me know if it worked.

Edit

what browser are you testing on ? by any chance safari ? , i gues i figured out you're problem , the url stays the same becouse there is a download file at the requested uri , some browsers don't change the url when you're requesting a file for download ( that would mean the users sees a blank page ) , i know safari 4 does this tough i don't know any solution for it ( maybe change all you're links in you're site to the new uri but you still have a problem for google indexed uri's )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜