I'm using file_get_contents()
to grab content from a site, and amazingly it works even if the URL I pass as argument redirects to another URL.
The problem is I need to know the new URL, is there a way to do that?
I'm using file_get_contents()
to grab content from a site, and amazingly it works even if the URL I pass as argument redirects to another URL.
The problem is I need to know the new URL, is there a way to do that?
<?php
header("Status: 301 Moved Permanently");
header("Location:./content/index.html?". $_SERVER['QUERY_STRING']);
exit;
?>
It seems that your nginx configuration is causing the problems.
Its totally possible that nginx is modifying the response headers. This is not by default - you could have a configuration that is aimed for it to behave as a reverse proxy etc.
Have you tried testing the redirect on a nginx with its default configuration?
My Problem is now solved, thanks to google and Daniweb here is solution
Dim req As HttpWebRequest = DirectCast(HttpWebRequest.Create("Your short URL here"), HttpWebRequest)
Dim response As HttpWebResponse
Dim resUri As String
response = req.GetResponse
resUri = response.ResponseUri.AbsoluteUri
MsgBox(resUri)
this will return URL_2.
You might make a request with cURL instead of
file_get_contents()
.Something like this should work...
Source