Hi, i have links that redirected to some pages like
http://www.domain.com/redirect.php?id=213
i want to learn page that redirected from this links.
how can i do it?
thank you....
How can i learn redirected page?
Moderator: General Moderators
Re: How can i learn redirected page?
Code: Select all
echo $_SERVER['HTTP_REFRER'];Re: How can i learn redirected page?
no i cant explain clearly sorry....
http://www.domain.com/redirect.php?id=213 => http://www.domain2.com/news.php?id=23432
like this and i want to learn this from my web site... my database has link that redirect(domain.com in example), but i want to collect redirected original web site (domain2.com in example.)
http://www.domain.com/redirect.php?id=213 => http://www.domain2.com/news.php?id=23432
like this and i want to learn this from my web site... my database has link that redirect(domain.com in example), but i want to collect redirected original web site (domain2.com in example.)
Re: How can i learn redirected page?
If you use cURL you can find out where you get redirected.
Code: Select all
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_NOBODY, 1);
curl_exec($curl);
$info = curl_getinfo($curl);
echo "Final location: ", $info["url"];Re: How can i learn redirected page?
Code: Select all
$query = mysql_query("SELECT * FROM links WHERE id=\"{$_GET['redirect']}\""); //sends query t
if(mysql_num_rows($query) > 0){ //checks if there is record in mysql with id typed in url
$row = mysql_fetch_array($query); //add line into array listed by id
mysql_query("UPDATE links SET clicks=clicks+1 WHERE id={$_GET['redirect']}"); //my links has clicks so it updates it
echo " <meta http-equiv=\"REFRESH\" content=\"0;url={$row['link']}\">"; //makes browser redirect to that page with id listed on url
}else {
echo " <meta http-equiv=\"REFRESH\" content=\"0;url=$site_link\">"; //else it redirects to main page
}- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: How can i learn redirected page?
Just personal preference, but I tend to execute redirects with:
Code: Select all
header("Location: $URL");
exit();Re: How can i learn redirected page?
semas wrote:Im using this code to redirectCode: Select all
$query = mysql_query("SELECT * FROM links WHERE id=\"{$_GET['redirect']}\""); //sends query t if(mysql_num_rows($query) > 0){ //checks if there is record in mysql with id typed in url $row = mysql_fetch_array($query); //add line into array listed by id mysql_query("UPDATE links SET clicks=clicks+1 WHERE id={$_GET['redirect']}"); //my links has clicks so it updates it echo " <meta http-equiv=\"REFRESH\" content=\"0;url={$row['link']}\">"; //makes browser redirect to that page with id listed on url }else { echo " <meta http-equiv=\"REFRESH\" content=\"0;url=$site_link\">"; //else it redirects to main page }
A little from the first post and a little from the second:greyhoundcode wrote:Just personal preference, but I tend to execute redirects with:
Code: Select all
header("Location: $URL"); exit();
Code: Select all
header('Refresh: 0');