Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2003
    Posts
    52

    Question Randomly selecting different index page on each load?

    I'm looking for the easiest and best way to have a different index.html file to load (randomly) each time someone visits my domain. I made 4 designs that I want to randomly load. I thought I could use the Cpanel random HTML feature in the scripts library, but I'm not entirely sure how that'd work. Any ideas on this?

    I know of a way to do this in javascript, but is there any non-javascript way since some people disable javascript?

  2. #2
    Join Date
    Jul 2002
    Location
    UK
    Posts
    2,027
    Use php to randomly select the page.

    Although personally I would have one page with 4 selectable skins, instead of 4 seperate pages. Updating content will be a nightmare for you.
    Gone.

  3. #3
    Yes, don't use JavaScript. You can do this serverside w/ ASP or PHP. You can write a small simple function that rotates your designs randomly.

  4. #4
    Join Date
    Nov 2003
    Location
    Online
    Posts
    1,217
    use php to select ransomly designs or templates in inxed file.

  5. #5
    Join Date
    Aug 2003
    Posts
    52
    Thanks for the expert advice everyone. It sounds like I should use php. Can someone direct me to a relevant php script that would work in the manner described? I'll be doing a search on my own but I'd be greatful for some suggestions. Thanks.

  6. #6
    Join Date
    Aug 2003
    Posts
    52
    OK, I found this simple php code to do the trick:

    <?php
    srand((double)microtime()*1000000);
    $thistimeindexfile = rand(1,4).".html";
    include($thistimeindexfile);
    ?>

    The problem is that I have this running on an addon domain on a linux cpanel server. When it forwards to one of the 4 html files, the URL then changes to:

    myaddondomain.com.mymaindomain.com.

    Obviously I don't want this (I don't want it to be obvious this is an addon domain, I want it to remain as thedomainthesepagesareon.com) if that makes any sense. Any ideas why this is occuring and how to prevent it?

  7. #7
    Join Date
    Aug 2003
    Posts
    52
    Anyone wanna take this on? There has to be a way so it shows the domain without showing it as just an addon domain .. daamn
    so close..

  8. #8
    Patrick:

    If it takes your to sub.domain.com then you might just have a extra "." in your code. Email me, I have working random code for you if yours doesn't work.
    Adrian K.

    AwesomePHP.com - Turnkey PHP Scripts with PayPal IPN

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •