1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

PHP how to hide affiliate links

Discussion in 'Web Development' started by bmcoll3278, Sep 10, 2009.

  1. bmcoll3278

    bmcoll3278 New Member

    How to cloak affiliate links
    Do you have affiliate links on your site that you want to hide? It is easy to do with this little script from bmcoll.com and its free. Very easy to install. This post will guide you through it even if you know very little about php programing.

    This next part is also included in the read me file that comes with the script.
    Enjoy!!

    how to install

    1 create a folder on your server called redirect . You can use another name if you choose just

    be sure to make the correct changes in the other files.

    2 Open the file called .htaccess
    Change the line that says ( www.bmcoll.com ) to your domain name
    ( catioun only change the www.bmcoll.com ) leave the rest of the line alone!!

    3 open the file
    index.php
    You will see lines that look like this
    "bmcoll"=>"http://www.bmcoll.com",

    "google"=>"http://www.google.com",

    "ebay"=>"http://www.ebay.com",

    "wall"=>"http://www.walmart.com",

    "snoops"=>"http://www.snoops.com/",

    "cj"=>"http://www.cj.com/",

    "yahoo"=>"http://www.yahoo.com/",

    "msn"=>"http://www.msn.com/"

    As long as you keep the same format you can add as many lines as you want
    Here is how it works look at the first line lets break it down

    "bmcoll" This is the shortcut name for the link you are cloaking.
    "http://www.bmcoll.com" This is the address where you want the user to be sent

    So change bmcoll to the name of your choice,And change the http://www.bmcoll.com to where you

    want to send them.

    Now you are ready to upload them to your server
    You created a folder called redirect . Now upload both files to that folder.

    Thats it. Now how to use it
    Thats very simple too Lets look again at the first link ( bmcoll"=>"http://www.bmcoll.com", )

    lets say you did not change that line. If you point your browser at

    http://www.yourdomain.com/redirect/bmcoll.html

    it would redriect you to my home page.

    So basicly once you create all your shortcut names in the file you just create the link like

    this

    http://www.yourdomainname.com/shortcut.html

    If you have further questions you can contact me at admin@bmcoll.com

    Thanks I hope this can be of use to you.


    Get the zip file here
    http://www.bmcoll.com/ebooks/redirect.zip


    Here is the code for those who want to copy and paste

    redirect.php
    Code:
    <?php
    $goto = strtolower($_GET["name"]);
    
    $sites = array(
    
    "bmcoll"=>"http://www.bmcoll.com",
    
    "google"=>"http://www.google.com",
    
    "ebay"=>"http://www.ebay.com",
    
    "wall"=>"http://www.walmart.com",
    
    "snoops"=>"http://www.snoops.com/",
    
    "cj"=>"http://www.cj.com/",
    
    "yahoo"=>"http://www.yahoo.com/",
    
    "msn"=>"http://www.msn.com/"
    
    
    	);
    
    
    
    header("HTTP/1.1 301 Moved Permanently");
    
    redirect;header("Location: " . $sites[$goto]);
    exit();
    
    ?>
    

    .htaccess
    Code:
    Options +FollowSymLinks
    RewriteEngine on
    
    
    RewriteRule (.*)\.html$ http://www.bmcoll.com/redirect/index.php?name=$1 
     
  2. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    a viable solution to mask those long link names which look like you are being scammed (avg viewer) I don't subscribe to the links being hijacked and lost revenue theory.

    I do believe to be safe you need to put redirect.php into it's own password protected directory and set your .htaccess file as to not allowing viewing or indexing if you do not want be penalized by all the search engines.
    If you think about it you could do away with the php file and just load it up into the .htaccess file using wildcards
    or specify each one
    I would also be concerned with some sorta of counting included in the script to see the click through rate.
     
  3. bmcoll3278

    bmcoll3278 New Member

    It is a basic script. I stuck to php for 2 reasons
    1 I dont know much about modrewrite yet
    2 the average guy looking for a solution on line will feel more comfortable with php.

    I dont believe the links high jacked either.
    But making the links search engine friendly is the goal behind the script.
    Thanks Dave for the input.
    When I have some spare time I will try to add to the script so it counts hits But if I do I do not like flat data bases so it will be with sql.

    A question for you dave. Can a .htaccess file be written with php fopen or file write?

    I have no idea I have never tried it. Maybe I will try it.
     
  4. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    no - you are talking directly with the server in it's own language.
    it's like you have the master key to get in, set things up to run the way you want to and leave. if you could use another language to set the server, it would open you up to attacks.
    you set up your data base in it's language - you can talk to it to get info in php, but can not change the structure of it.
     
  5. bmcoll3278

    bmcoll3278 New Member

    ok Thanks again. By the way the pm from you and covertpea, I sent a reply.

    I would be glad to help any way I can.
     
  6. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    Ok by the way your contact admin is not uploading . it's returning a error page.
     
  7. bmcoll3278

    bmcoll3278 New Member

    Thanks I forgot I deleted the thankyou page. I fixed it . it just send you back to the main page now.

    Did you see I got the html repair script to output a numbered list like you asked.
     
  8. togu25

    togu25 New Member

    I will download and try it
     
  9. bmcoll3278

    bmcoll3278 New Member

    let me know if you have questions
     
  10. vareside

    vareside New Member

  11. bmcoll3278

    bmcoll3278 New Member

    The point is a way to do it on your own site there are plenty of services like tinyurl that will do it. I am just showing a way to do it yourself if you dont want to use a service.
     
  12. vareside

    vareside New Member

    maybe a basis?

    Well, I know how to redirect a user to a specific address using just two very very flat files. The editing thing of the storage of the abbreviations or numbers or letters that are very often randomly chosen by the short URL generator has to be done by someone else. I don't know that part.

    Anyway, you need two files to make a redirect looking this way:
    ENTER: abc.de/?123456
    REDIRECTED TO: what.ever.com/article.php?ylt=123456

    The first file is the index.php in the above exmaple. It contains the following code:

    PHP:
    <?php

      $file
    ["db"]    = "http://abc.de/database.csv";
      
    $file["split"] = ";";
      
    $url["backup"] = "http://www.vareside.com/";
      
    $fp fopen ($file["db"],"r");
      while (
    $data fgetcsv ($fp4096$file["split"]))
      {
          if (
    $data[0] == $_SERVER["QUERY_STRING"])
          {
              
    fclose ($fp);
              
    header ("Location: " $data[1]);
              exit;
          }
      }
      
    fclose ($fp);
      
    header ("Location: " $url["backup"]);

    ?>
    This is where to find the number/letter/abbrev. codes, in the example stored in the database.csv file, where to split code and actual URL the user will be redirected to and what to do if there is no code available/a wrong code, which is in the example to redirect back to vareside.com :: discover the useful, my website.

    What we do now is fill the database.csv file with the following examplemantary content.

    Code:
    vareside;http://www.vareside.com/
    twitter;http://twitter.com/thecoventgarden
    vareside2;http://www2.vareside.com/
    vareside3;http://www3.vareside.com/
    vareside4;http://www4.vareside.com/
    So, if we enter the domain of the first example again and want to enter my twitter profile, we just access
    abc.de/?twitter
    and everything is fine.

    I hope that helps a bit.

    Sincerely,
    Max

    PS: Please mention me somewhere in source code if you use that script or simply follow me on Twitter. Thanks.
     
  13. thess

    thess New Member

    Very good php trick.
    Thanks for sharing