How can I Decrypt and Redirect to a Different Link?

by 3 replies
4
Hi,

I would like to do this:

Redirect http://mindreality.com/cb/?a=btXAypit2&p=2

To: http://mindreality.com/ez/go.php?offer=pelmansec&pid=2

What happens is that "btXAypit2&" is an encrypted ClickBank id, and I know the key code such as "a" = "2", "b" = "s", "1" = "8" etc...

I would like to be able to do TWO Things.

1. Decrypt a certain part of a URL

2. Redirect to another URL with the data

3. Transform and Pass other parameters as well such as "&p=2" becomes "&pid=2"

What I am really trying to do is to redirect all "ClickBank Hopguard" Affiliate links to "Easy Click Mate" Affiliate links.

So the above method is a way do it. I just need to know how to implement the exact code/script required. I think it would be uploaded to the folder where my hopguard is installed "http://mindreality.com/cb/"

Any suggestions?
#programming #based #code #decrypt #link #redirect
  • You can do this with javascript. I don't know php, but I am sure you can do it with php as well. In the example, the encrypted clickbank id should be "btXAypit2" without the ampersand as the ampersand separates parameters.

    You can do this by adding this javascript to the page you are working in at:

    "http://mindreality.com/cb/"

    The default page there "index.html" or "default.php", whatever it may be called.

    Here is the javascript:

    Code:
    <script type="text/javascript">
    
    function getParameterByName(name) {
        name = name.replace(/[[]/, "[").replace(/[]]/, "]");
        var regex = new RegExp("[?&]" + name + "=([^&#]*)"),
            results = regex.exec(location.search);
        return results == null ? "" : decodeURIComponent(results[1].replace(/+/g, " "));
    }
    
    function redirect()
    {	
    	var a = getParameterByName('a');
    	var p = getParameterByName('p');
    	
    	window.location.href = 'http://mindreality.com/ez/go.php?offer=' + a + '&pid=' + p;
    }
    
    </script>
    And in the html, you would call the redirect method like this:

    HTML Code:
    <body onLoad="redirect()">
    </body>
    • [ 1 ] Thanks
    • [1] reply
    • Thanks!

      I'm trying to understand how the code works.

      Starting with: How does it know which part of the link I am trying to read?
      • [1] reply

Next Topics on Trending Feed