Rotating Links Through html or php

5 replies
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?
#html #links #php #rotating
  • Profile picture of the author jlandells
    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.
    {{ DiscussionBoard.errors[3463993].message }}
  • Profile picture of the author Filter
    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
    {{ DiscussionBoard.errors[3484856].message }}
    • Profile picture of the author sonia2012
      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.
      {{ DiscussionBoard.errors[3485665].message }}
      • Profile picture of the author McBob
        Originally Posted by sonia2012 View Post

        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.
        Not necessarily. He could simply replace the index.html in his aff-link directory with an index.php file or he could put an .htaccess file in his aff-link directory to have the server parse his *.html file as php.
        {{ DiscussionBoard.errors[3485707].message }}
  • Profile picture of the author McBob
    <?

    $textfile ="yourlinks.txt";

    $items = file("$textfile");

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

    echo $items[$item];

    ?>
    {{ DiscussionBoard.errors[3485648].message }}

Trending Topics