1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with code

Discussion in 'Making Money' started by workoutsforteens, Mar 5, 2012.

  1. workoutsforteens

    workoutsforteens Junior Member

    Joined:
    Nov 28, 2011
    Messages:
    170
    Likes Received:
    137
    Hello BHW, I was wondering if anyone knew of a redirect code that would randomly redirect to multiple web addresses you select.

    For example the first visitor would be redirected to my blog
    The second would be directed to my youtube video
    And the third would be directed to an article I wrote.

    Anyone know of some code that'll do that?

    Thanks
     
  2. mic22

    mic22 Newbie

    Joined:
    Apr 3, 2010
    Messages:
    37
    Likes Received:
    10
    PHP or what?
     
  3. workoutsforteens

    workoutsforteens Junior Member

    Joined:
    Nov 28, 2011
    Messages:
    170
    Likes Received:
    137
    I want my blogger blog to redirect to random pages that I choose.

    And yes PHP
     
  4. mic22

    mic22 Newbie

    Joined:
    Apr 3, 2010
    Messages:
    37
    Likes Received:
    10
    It can be done this way:
    PHP:
    <?php
    $urls
    =array('hXXp://google.com''hXXp://facebook.com''hXXp://twitter.com'); // XX->tt cuz I can't post urls
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: '.$urls[rand(0count($urls)-1)]);
    ?>
     
    • Thanks Thanks x 1
  5. workoutsforteens

    workoutsforteens Junior Member

    Joined:
    Nov 28, 2011
    Messages:
    170
    Likes Received:
    137
    i tried that but its not redirecting for some reason
     
  6. mic22

    mic22 Newbie

    Joined:
    Apr 3, 2010
    Messages:
    37
    Likes Received:
    10
    Any errors/warnings shows?
    If any, try
    PHP:
    <?php
    ob_start
    ();
    $urls=array('hXXp://google.com''hXXp://facebook.com''hXXp://twitter.com'); // XX->tt cuz I can't post urls 
    header('HTTP/1.1 301 Moved Permanently'); 
    header('Location: '.$urls[rand(0count($urls)-1)]);
    ob_end_flush();
    ?>
     
    • Thanks Thanks x 1
  7. workoutsforteens

    workoutsforteens Junior Member

    Joined:
    Nov 28, 2011
    Messages:
    170
    Likes Received:
    137
    no it doesn't say error or anything... but i check to see if its redirecting it doesnt. and then i go back to see if the code is still in place and its gone. and thats weird cuz it said "saved" when i clicked save template

    This is true for both codes
     
  8. mic22

    mic22 Newbie

    Joined:
    Apr 3, 2010
    Messages:
    37
    Likes Received:
    10
    I'm not familiar with Blogger platform so I can't help you, sorry.
     
  9. workoutsforteens

    workoutsforteens Junior Member

    Joined:
    Nov 28, 2011
    Messages:
    170
    Likes Received:
    137
    I appreciate you trying to help. Thanks. If I find a code that works I'll post it here.

    Cheers!
     
  10. workoutsforteens

    workoutsforteens Junior Member

    Joined:
    Nov 28, 2011
    Messages:
    170
    Likes Received:
    137
    I found it!


    <script type="text/javascript">

    var urls = new Array("http://www.url1.com/", "http://www.url2.com/");

    function redirect()
    {
    window.location = urls[Math.floor(urls.length*Math.random())];
    }

    var temp = setInterval("redirect()", 3000);

    </script>
     
  11. zackm

    zackm Junior Member

    Joined:
    Dec 11, 2010
    Messages:
    145
    Likes Received:
    26
    You mean someone will be redirected if they land on your blogspot?

    Not worth it bro. I've tried this a lot of times. It does work but somehow G is good at detecting when you start sending/receiving mass amt of traffic to the blogspot.