• Resolved mikeboy3

    (@mikeboy3)


    Greetings fellow “WordPressers”,
    I have a problem, I hired a shared hosting plan and my blog outgrew it, so now, they throttled my blog’s domain so that I didn’t take up all the Apache’s connections.

    I came up with a solution that would fix the problem, however, I don’t know how to implement it.
    It turns out that since my blog is on a sub-domain, all my other sub-domains are not throttled, so, I created a clone blog that I would like to redirect the users and share the load while I get a bigger server!

    However, I tried using this code:

    <script type="text/javascript">
    <!--
    window.location = "http://avatar2.iamzaks.com/"
    //-->
    </script>

    and calling it as one of my rotating ads, (I use OpenAds) however, that does not work since I cannot add some random javascript to the banner code, and I dont want all my users to get redirected, that would generate the same issue on the clone site.

    Is there another way to automatically redirect some random users to the clone site?

    And if there isn’t it, would be nice to develop one.

    Thanks in advance for your replies.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Sure. Create a plugin like this:

    `
    <?php
    /*
    put a plugin name here.
    Copy the stuff in one of your other plugins
    */

    function sometimesRedirect(){

    }

    Oops, accidentally hit submit. Here goes again:

    <?php
    /*
    put a plugin name here.
    (Copy the format from one of your other plugins)
    */
    
    function sometimesRedirect(){
       if ( 50 < rand(0, 100) )
          header('Location: http://avatar2.iamzaks.com/');
    }
    
    add_action('init', 'sometimesRedirect')
    ?>

    As you can probably figure out, that will redirect people half the time. Make the 50 smaller if you want it less frequent.

    Thread Starter mikeboy3

    (@mikeboy3)

    thanks for your reply mate, but, Im not good with codes, could you ellaborate a little more? like where does the url go and such.

    I already put your URL in there (the one from your javascript example). Just paste exactly what I wrote into a file, upload it to your plugins directory, activate it, and you’re done.

    You’ll need to put something where I wrote “Put a plugin name here” or else it won’t show up in the plugins activation menu. Just copy the stuff from the top of another plugin and change the name.

    Done.

    Sorry for the confusion: Adamrbrown’s second post was temporarily held by the spam filters. I released it, but now your replies are a bit out of sync.

    Thread Starter mikeboy3

    (@mikeboy3)

    thank you very much for your help, before the code did not show entirely, thanks a lot

    Ahh, I see the filters must have used “bozo” mode or whatever BBPress calls it, because I saw the post as if it had published… thus my confusion.

    Similar result, but no worries, you weren’t bozo’d. 🙂

    This bbPress board runs Akismet. I just had to “un-spam” that particular post.

    Glad to hear it.

    I just noticed a small bug in that function I wrote, mikeboy. Change the function like so or you’ll be hemorrhaging bandwidth:

    function sometimesRedirect(){
       if ( 50 < rand(0, 100) ){
          header('Location: yourLinkGoesHere');
          die;
       }
    }

    I left the link out this time to avoid setting off Akismet again, but you’ll figure it out.

    Thread Starter mikeboy3

    (@mikeboy3)

    ok, thanks for the code, it works great!

    however, there is a small problem that is not that urgent, the user is redirected to only one url, so if he clicks on a page or a post, when he is redirected, he is taken to the index again, and has to start over, that might be annoying (got a few emails about it already, people do love to complain) is there a way to direct them to the equivalent of where they where in the clone page?

    Thread Starter mikeboy3

    (@mikeboy3)

    adamrbrown, since I edited the code with the corrected bug, the redirection does not work, could you please check it again.
    Thanks in advance

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Need to redirect some random users’ is closed to new replies.