Results 1 to 9 of 9
  1. #1

    Redirect Based on Week of Month

    Is there any way that in php or any other language that I can redirect based on the week of the month. So for example if it's the 1-7th it would go to example.com/week1.php and for the 8-14th it
    would go to example.com/week2.php?

    Thanks

  2. #2
    Join Date
    Apr 2008
    Posts
    306
    Sure! And in a single line :

    PHP Code:
    header('Location: week' date('N') . '.php'); 
    Where "date('N')" equals 1 for Monday and 7 for Sunday.
    Heymman - Beefy servers, tiny price !

  3. #3
    Am I doing this right. Would I put for example;
    header('Location: week' . date('11') . 'google.co.uk');
    between the <head> and </head> tags?

    Thanks

  4. #4
    Join Date
    Mar 2009
    Location
    Gods Own Country
    Posts
    681
    header('Location: week' . date('N') . '.php');
    That is for day of the week, not week of the month.
    Fabin Mundattil @ Xieles Support
    High Quality Server Management | support @ xieles.com
    http://xieles.com

  5. #5
    Yeah but you can adapt it and it should work; is this code right

    <?php
    header('Location: week' . date('11') . 'http://google.com');
    ?>
    As it doesn't seem, to work?

  6. #6
    Join Date
    Mar 2009
    Location
    Gods Own Country
    Posts
    681
    why google.com? to which page should it redirect?
    Fabin Mundattil @ Xieles Support
    High Quality Server Management | support @ xieles.com
    http://xieles.com

  7. #7
    Quote Originally Posted by fabin View Post
    why google.com? to which page should it redirect?
    It's a page on the intranet, so was just using google as an example
    My Site is Silicox Valley Technology
    Follow me on Twitter, @person287

  8. #8
    Join Date
    Apr 2008
    Posts
    306
    Quote Originally Posted by fabin View Post
    That is for day of the week, not week of the month.
    Right! I've been reading the question too quikcly.

    This should do the trick :


    PHP Code:
    header('Location: week' . (floor((date('j') - 1) / 7) + 1) . '.php'); 
    Insert this between PHP tags and you're good to go.
    Heymman - Beefy servers, tiny price !

  9. #9
    That works great! Thank you very much.
    My Site is Silicox Valley Technology
    Follow me on Twitter, @person287

Similar Threads

  1. Redirect based on referrers
    By hardjoko in forum Hosting Security and Technology
    Replies: 1
    Last Post: 08-25-2008, 10:18 PM
  2. Replies: 0
    Last Post: 06-10-2008, 06:16 PM
  3. Replies: 12
    Last Post: 08-13-2006, 01:55 AM
  4. redirect based on variables
    By BowlingShoe in forum Programming Discussion
    Replies: 1
    Last Post: 07-18-2006, 05:49 PM
  5. redirect based on traffic
    By buyourweb in forum Hosting Security and Technology
    Replies: 2
    Last Post: 01-08-2006, 08:47 AM

Posting Permissions

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