Today I was spending time updating some of the links across my sites that were setup in htaccess files, or in the virtual host files for redirects to my affiliate links. I was getting super bored, and a little bit pissed off.

Then I thought to myself, why am I not automating this so I only have to go to one place to update all the links across my sites.

Thanks mainly to Contempt.me for putting me in the automation/make myself even more lazy mindset on this one.

I’m really not a programmer, but I’ve been around it for 15+ years so I do have a slight familiarity with code. I figured this task would be easy enough to accomplish if I did a bit of reading. So, I sat down with a coffee and got to work figuring out how to make this little idea of mine a reality. Overall, it wasn’t very difficult even for a non programmer such as myself.

What my little script does is the following;

  • You upload it to your server after creating your database (explained later)
  • You create links on your site using a special URL (explained later)
  • The user clicks on it and is directed to the appropriate offer from the script.

Pretty simple when you think about it, but there’s a catch. What if something is wrong with the keyword or no keyword is entered at all? Well, not a problem when you have a default site created as well.

Yup, this script also checks if the keyword is missing or blank, and then will direct the user to a default site for the given domain. This is a great way to switch all your links out to the default link in a matter of seconds.

For example;

Say a user visits your site, and you have a simple link to your links script

The user then clicks on that link

The script then checks if there’s an affiliate link associated with the domain the click is coming from, and the keyword used on the link.

If no affiliate link is available for that particular site and keyword, it will then check if there’s a default link for the particular site.

If no affiliate link is available as a default for the site either, then it will go on to reading a global default from the database.

but wait, i shit you not, there’s more.

If no affiliate link is available, or something’s wrong with the database, then it will use a hardset super world domination global link from the script itself.

That’s right, even if all hell is breaking lose, that user will still get to an affiliate offer of your choosing. This may not be totally targetted or anything, but at least you have full control over what the user is seeing the whole way down the chain on your sites.

You’re probably wondering how to install this little beast on your servers to try out. Well, it’s pretty easy after you create a shitload of configuration files, and then telnet to nasa and then .. no I’m just kidding, you just have to create a database, make 4 edits to the script, and then upload it and you’re done. Then you just have to fill up the database and you’re away to the races.

Requirements;

  • MySQL
  • PHP
  • Web Server
  • About 5 minutes of your time

Here’s how to install this bad boy;

  1. Download the Automatic Link Updating PHP Script and Database files
  2. Create a new database on your server name it something creative if you enjoy
  3. Create a user that has access to the database, similarly creative name and password an option here too for you artistic folk out there. Read only access is fine, man.
  4. Now insert the SQL included in the archive to your database, we even have some sample entries in there for you. You can do this using PHPMyadmin or whatever.

Change the following in the SQL if you want it to work right out of the box for testing;

All references to “yourdomain.com” must become your actual domain.

  1. Now you’re ready to edit the links.sql file included. Change the following items in there;

       hardlink – set this to whatever you want the super duper global link to be when all else fails  
       dbhost – set this to teh database host  
       db user – set this to the database user  
       dbpass – set the database password  
       dbname – set the database name
    
  2. Upload links.php to your server

You’re essentially done, but of course, you should test everything. This is how you do that.

Testing things out

First you should hit up phpmyadmin, and change any of the links or keywords, but we’re going to assume you’re lazy and just went with our defaults, only changing your domain name (this is a must, if you didn’t do this, go do it now!).

First test the script works, by hitting here;

http://yourdomain.com/links.php

That should take you off to lulz.com

Now, test the script for your domain and keywords

http://yourdomain.com/links.php?sendto=trink

That should zip you off to bingo.com

Now if you want to get extra fancy, go in and edit the sql, and change the keyword “default” on your domain, and put it to something like pizza or whatever you like.

http://yourdomain.com/links.php?sendto=whatever

Now hit your site again, and it should take you to digg.com

If you see digg, bravo. You can also run through and remove the “default” keyword from the global default item in the database to test out the super duper global default site you hardcoded in the script earlier.

If you did decide to test out the global default, without changing anything you probably see wickedfire.

Final Setup Stuffz

Congratulations, your shit is working and you’re now automated.

All that needs to be done now is go through PHPMyadmin and add a bunch of sites to your list, and keywords, and affiliate links. This will let you do creative things like have all sorts of subid’s across your pages to create your own heatmaps or other things, and lets you have super fine control if all your links die and you quickly want to redirect everything to a default link.

Note that for the sitename, you will have to enter it without the www, otherwise the script will get confused because it’s stripping those off to make everything nice.

Just add links to your site like the following

http://yourdomain.com/links.php?sendto=keyword

I guess you could use nofollow on there too, not sure if it’d be beneficial or not though.

Obviously eventually i’ll get around to creating a GUI backend for this, and a few more features will be added, but for now it’s good enough for me, and probably a lot better than what a lot of you are using.