everybody. I have a URL:
http://www.baomoi.com/thanh-nien-tim-hieu-thong-tin-bau-cu-dai-bieu-quoc-hoi/r/19140036.epi
If I browse the URL by a browser, the URL will be redirected and move to a new URL as below:
http://www.tienphong.vn/gioi-tre/thanh-nien-tim-hieu-thong-tin-bau-cu-dai-bieu-quoc-hoi-993059.tpo
I want to code a PHP function to get the New URL. I read a lot of section using curl, but I only get the URL instead of the New URL. I am looking forward to hearing your reply. Thank you!
Use PHP Permanent redirection using header()
.
Put following code in your file from where you want to redirect.
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.tienphong.vn/gioi-tre/thanh-nien-tim-hieu-thong-tin-bau-cu-dai-bieu-quoc-hoi-993059.tpo");
exit();