Rotating Links Through html or php

by 5 replies
7
Whenever I promote an affiliate link I have the very basic structure that most people have that is basically just set up like somedomain.com/go/aff-link

The index.html file of the aff-link directory would just be something like this;

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
<meta http-equiv="Refresh"
content="1; URL=aff link address here" target="_blank">
<TITLE>Title</TITLE>
<META NAME="ROBOTS" CONTENT="NONE">
</head>
<body>
<br />
</body>
</html>
However, I was wondering what I should do if I wanted to rotate between 2 different urls.

Basically, if you were to visit somedomain.com/go/aff-link it would rotate between 2 or however many url's you had set up.

Is it possible to edit the above html to do this or would I need to use php?

What is the easiest way to do this?
#programming #html #links #php #rotating
  • Hi Pat,

    Your challenge here would be in how you want to track things. Bear in mind that HTML is inherently stateless, so each time you load the page, it doesn't know anything about the previous invocation. There are eseentially 2 ways to get round this:

    1) You could make it random, in which case I think you could get away with a bit of Javascript in the HTML, or code opt for PHP (for greater compatibility);

    2) You could use PHP to track this either in a database. However, it may be overkill to implement a database just for this function, unless you want to do this for many sites.

    There are also additional methods using server-side CGI, but these are more complex.

    Does that help at all?

    Cheers,
    -John.
  • Hey Pat

    Personally, I'd use a really simple php rotator. I put the code up for one in this topic a few weeks back, feel free to use it:

    http://www.warriorforum.com/ad-netwo...ml#post3320071


    Cheers
    • [1] reply
    • First thing first, you need to enable the rewrite rule "mod_rewrite"
      let's say your dynamic url somedomain.com/go.php?aff-link=123
      become somedomain.com/go/aff-link/123

      then use random in php script.
      • [1] reply
  • <?

    $textfile ="yourlinks.txt";

    $items = file("$textfile");

    $item = rand(0, sizeof($items)-1);

    echo $items[$item];

    ?>

Next Topics on Trending Feed

  • 7

    Whenever I promote an affiliate link I have the very basic structure that most people have that is basically just set up like somedomain.com/go/aff-link The index.html file of the aff-link directory would just be something like this;