Script/Code/HTML for redirecting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lbazso
    Confirmed User
    • Jan 2012
    • 472

    #1

    Script/Code/HTML for redirecting

    Hey Guys,

    I am redirecting traffic to an url and from there I would like to create/copy a code/script/html (whatever works) so when the traffic comes in, it could not just redirect to 1 url but to randomly use one from a list of url's each time or every 5th time for example.

    I hope I wrote it clearly. I am trying to explain it the best I can!

    I would really appreciate some help or advise!

    Thanks so much!

    Laszlo
  • Best-In-BC
    Confirmed User
    • Jun 2002
    • 9511

    #2
    I use to have a php script that just picked a random url out of a text file to go to. Is this what your talking about ?
    Vacares - Web Hosting, Domains, O365, Security & More
    Unparked domains burning a hole in your pocket? 5 Simple Ways to Make Easy $$$ from Unused Domains

    Comment

    • lbazso
      Confirmed User
      • Jan 2012
      • 472

      #3
      Originally posted by Best-In-BC
      I use to have a php script that just picked a random url out of a text file to go to. Is this what your talking about ?
      That sounds about right!

      Does it redirect too?

      Thanks in advance!

      Comment

      • lbazso
        Confirmed User
        • Jan 2012
        • 472

        #4
        I am still looking for a script. If anyone can help, it would be greatly appreciated. Thanks!

        Comment

        • lbazso
          Confirmed User
          • Jan 2012
          • 472

          #5
          Originally posted by lbazso
          I am still looking for a script. If anyone can help, it would be greatly appreciated. Thanks!
          Never mind. I have found one and it works:

          Code:
          <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()", 1000);
          
          </script>

          Comment

          • Nevet
            Registered User
            • Dec 2011
            • 10

            #6
            That won't work for users without Javascript, of course.

            Comment

            • lbazso
              Confirmed User
              • Jan 2012
              • 472

              #7
              Originally posted by Nevet
              That won't work for users without Javascript, of course.
              Thanks!

              Comment

              • alcstrategy
                Confirmed User
                • May 2012
                • 124

                #8
                here is a very simple example in php

                <?php
                $urls = file('urls.txt');
                $rand = array_rand($urls);
                header("Location: {$urls[$rand]}");
                ?>

                in urls.txt make each line a url

                this is just a simple example and should be put before output otherwise you technically could put ob_start() at the beginning and supress output

                Comment

                • Zeiss
                  Confirmed User
                  • May 2012
                  • 5189

                  #9
                  Better go the php way as above.


                  Adult Webmasters Guides

                  Comment

                  • RaunchyRepublic
                    Registered User
                    • Jan 2011
                    • 41

                    #10
                    This is SEO suicide too, you know that right?
                    Raunchy Republic Sex Shop
                    Australia's Favourite Online Adult Store
                    Visit our Sex Blog

                    Comment

                    • lbazso
                      Confirmed User
                      • Jan 2012
                      • 472

                      #11
                      Originally posted by RaunchyRepublic
                      This is SEO suicide too, you know that right?
                      Yeah, I am aware of that. It has a different purpose.

                      Comment

                      • lbazso
                        Confirmed User
                        • Jan 2012
                        • 472

                        #12
                        Originally posted by Zealotry
                        Better go the php way as above.
                        Thanks for your input!

                        Comment

                        • lbazso
                          Confirmed User
                          • Jan 2012
                          • 472

                          #13
                          Originally posted by alcstrategy
                          here is a very simple example in php

                          <?php
                          $urls = file('urls.txt');
                          $rand = array_rand($urls);
                          header("Location: {$urls[$rand]}");
                          ?>

                          in urls.txt make each line a url

                          this is just a simple example and should be put before output otherwise you technically could put ob_start() at the beginning and supress output
                          Thanks so much! Appreciate it!

                          Comment

                          • alcstrategy
                            Confirmed User
                            • May 2012
                            • 124

                            #14
                            no problem. It's very simple but if you need any more help with it just let me know

                            Comment

                            • lbazso
                              Confirmed User
                              • Jan 2012
                              • 472

                              #15
                              Originally posted by alcstrategy
                              no problem. It's very simple but if you need any more help with it just let me know
                              Thanks again and I will contact you!

                              Comment

                              • lbazso
                                Confirmed User
                                • Jan 2012
                                • 472

                                #16
                                Originally posted by alcstrategy
                                no problem. It's very simple but if you need any more help with it just let me know
                                Hi again,

                                I just would like to let you know that I have made my first sale since I have started using your php code! Thank you so much!!!!

                                Laszlo

                                Comment

                                • alcstrategy
                                  Confirmed User
                                  • May 2012
                                  • 124

                                  #17
                                  ha no problem glad I could help

                                  Comment

                                  • lbazso
                                    Confirmed User
                                    • Jan 2012
                                    • 472

                                    #18
                                    Originally posted by alcstrategy
                                    ha no problem glad I could help
                                    It's fantastic!!!! :D

                                    Comment

                                    Working...