Jump to content

Rewriting An External Link


allison

Recommended Posts

Let me apologize right off for this is going to sound pretty green.  I am fairly new to PHP and am trying to find a solution to a slight issue.

 

I have advertising links on my site which I would like to somehow mask....  For example let say I have an ad from CJ.  The ad link would look like [noparse]www.anrdoezrs.net/click-2188900-10412099[/noparse].  Ideally, I'd love for the link to read [noparse]www.1800contacts.com[/noparse].  I know you'd still be able to see the other address(es) in the Status Bar of your browser as the link is accessed, but that's not really a concern.

 

Here is an example of another site doing this in a slightly different way:  http://www.cheapcheapcheap.org/forums/showthread.php?t=30112

 

I'm more than willing to research all this myself, I just don't know what to search for. Any advice would be greatly appreciated!

 

Thanks!

 

Link to comment
Share on other sites

Not sure what you actually want here so if I go in the wrong direction, please put me right...

If you want the link label to be different to the actual link, then (and usually):

<a href="http://www.rawstar7.co.uk">my link</a>

Where it says 'my link' you can put anything you want...

Is this what your after?

 

 

P.S. This is a HTML question, not PHP

Link to comment
Share on other sites

Hi rarebit, thanks for your reply. :)

 

If you would, please take a look at the example link provided.  Note how he is utilizing PHP to redirect his link.

 

"Old Navy  has a $10 Off $50 Coupon: TAKE10. Expires 11/21."

 

The Old Navy link location is: [noparse]http://www.cheapcheapcheap.org/link.php?d=35966[/noparse]

 

Upon clicking you can see that the link goes through an affiliate link and then a redirect to the Old Navy site.

 

 

Ahhh....and I see the confusion now.  lol!  Sorry about that.  It's the mouseover bit I'm looking to hide.  ...what is seen in the status bar of your browser as well as what is given if you were to copy the link.  Does that make more sense?

 

 

Link to comment
Share on other sites

Sorry my ignorance...

Here's what I use for logging my downloads on a simple site...

<?php

function file_append($fn, $s)
{
$fp = fopen($fn, "a");	// use to append
//$fp = fopen($fn, "w");		// use to write
$written = 0;
while ($written == 0)	// keep trying until lock is free
{
	if (flock($fp, LOCK_EX))
	{
		fwrite($fp, $s);
		flock($fp, LOCK_UN);
		$written = 1;
	}
}
fclose($fp);

return 0;
}

if(isset($_GET['item']))
{
$log = "log.txt";
$dir = "dl/";
$item = $_GET['item'];

if ( (strcmp($item, "") != 0) && (file_exists($dir.$item)) )
{
	//	LOG
	$rip = $_SERVER['REMOTE_ADDR'];
	$time = $_SERVER['REQUEST_TIME'];
	$method = $_SERVER['REQUEST_METHOD'];
	$link = substr($_SERVER['REQUEST_URI'], 0, 128);
	$agent = substr($_SERVER['HTTP_USER_AGENT'], 0, 128);

	$s = $item." : ".$rip." : ".$time." : ".$method." : ".$link." : ".$agent."\n";

	//$s = "hi\n";
	file_append($dir.$log, $s);

	//	REDIRECT TO FILE
	header('Location: '.$dir.$item);
}
else
{
	print "<html><head><title>DOWNLOAD</title></head><body>REQUEST ERROR<br></body></html>";
}
}
else
{
print "<html><head><title>ERROR</title></head><body>NO REQUEST FOUND!</body></html>";
}

?>

 

And this is how I call it...

<a href="dl.php?item=cmsmonkey.0.1.0.tar.gz">cmsmonkey.0.1.0.tar.gz</a>

All files for dl are in a folder called dl...

The reason why i've put all this in here is to show why and how I log the action, hope this helps!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.