Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect Question - masking url in address bar 1

Status
Not open for further replies.

buspass

Programmer
Feb 2, 2003
29
GB
There may not be a php solution to this - but I will explain what I want to do first.

I want to be able to show a link in an article resource box that points to my root domain with a variable in the querystring - eg "
When clicked, my php script will $_GET["id"] the value of id and then open a text file to read the "page.html" on my domain that is associated to that id.

So id=1 might be cats.html, id=2 might be dogs.html and so on.

The idea is that I can show an appropriate page which will appear to be on home page. So I would need that to always appear in the address bar.

I can get it to work so the appropriate page is displayed but I always get in the address bar regardles of the page I am displaying.

Is there anyway to change the appearance of the url in the address bar so it loses the ?id=123 bit?

I have tried frames but cannot get it to work?

Any help and code snippet appreciated

Here's some code so far: I haev a text file id_list.txt to store page data in format 1,page1.html, 2,page2.html, etc

Code:
<?php

$id = $_GET["id"];
$root_domain =  $_SERVER['HTTP_HOST'];
$filename = "id_list.txt"; // this is where i store the html page names e.g. 1, page1.html, 2,page2.html etc, comma delimited
$fd = fopen ($filename, "r");
$contents = fread ($fd,filesize ($filename));
fclose ($fd);
$delimiter = ",";
$splitcontents = explode($delimiter, $contents);
//echo"<p>file $id = $splitcontents[$id]</p>";
?>
<HTML><HEAD>
<META NAME="description" CONTENT="<?=$root_domain;?>">
<META NAME="keywords" CONTENT="">
</HEAD>
<FRAMESET border=0 rows="100%,*" frameborder="no"
marginleft=0 margintop=0 marginright=0 marginbottom=0>
<frame src="<?=$splitcontents[$id];?>" scrolling=auto frameborder="no" border=0 noresize> <frame topmargin="0" marginwidth=0 scrolling=no marginheight=0
frameborder="no" border=0 noresize>
</FRAMESET>
</HTML>
 
Article directories such as ezine, prohibit direct links to affiliate pages from articles, unless you redirect to an aff page from your own domain. So if I link to from the article and then redirect the user to the affilaite page, that is okay - they will allow that. But I can't put an affiliate link in the article.

Likewise, I can have a link as I describe previously - which when visited displays the root domain but with affilaite content. They are okay with this as well.
 
Code:
$urlToFetch = '[URL unfurl="true"]http://www.myurl.com?myarticle=somevalue';[/URL]
$ch = curl_init($urlToFetch);
curl_setopt(CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($ch);
echo $contents;

no url rewriting takes place in the above code. that's a different question and much more complex.

depending on the configuration of the remote site you may need many more options to be set for the curl transfer.
 
I tried this:
Code:
$urlToFetch = '[URL unfurl="true"]http://abc.go.com';[/URL]
$ch = curl_init($urlToFetch);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
$contents = curl_exec($ch);
echo $contents;

which worked, echoing the page contents, but other urls didn't work. Clickbank affiliate urls did not work - for example:
Code:
$urlToFetch = '[URL unfurl="true"]http://8d9f1dz5v4lfir9jg8ro6rqdfx.hop.clickbank.net/?tid=TEST';[/URL]
just returned a '1'

I have a feeling it could work but seems it could be unreliable depending on the url
 
it's not the url so much as the server configuration at the destination. many servers prevent deep linking (requiring that referer's are set), others require that an agent string is set, others require that a session exists etc etc; others will deliver some javascript which in turn calls the page content (but will fail to do so due to cross-site scripting prohibitions).

I did say that it was a bad solution.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top