how to redirect 404 page to date?

Discussion in 'Programming' started by kuzukuzu2, Oct 29, 2012.

  1. #1
    hello,

    i want to redirect people to mydomain.com/dateoftoday if they come on my website page which doesnt exist

    so if they if its today 10/29/2012 and they acces a 404 page on my website it must redirect them to mydomain.com/10/29/2012 so they can see all new posts of today

    if they acces tomorrow (10/30/2012) it must redirect to mydomain.com/10/30/2012

    can somebody please help? i have 7$ in my paypal, i can give it to u if u want
     
    kuzukuzu2, Oct 29, 2012 IP
  2. netExelixis

    netExelixis Peon

    Messages:
    10
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can redirect with .htaccess using ErrorDocument 404 /404.php

    And then inside 404.php file get the date and redirect again to mydomain.com/10/29/2012.

    Example code:
    <?php
    $curDate = date("m/d/Y");
    $url="http://www.mydomain.com/".$curDate;
    header('Location:'.$url);
    ?>

    Let me know if this works.
     
    Last edited: Oct 29, 2012
    netExelixis, Oct 29, 2012 IP
  3. kuzukuzu2

    kuzukuzu2 Member

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #3
    hello,

    thnx, that works but it redirects like to : mydomain.com/10/29/12 and i want him to redirect to like: mydomain.com/10/29/12.html

    how to do this sir?
     
    kuzukuzu2, Oct 29, 2012 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    <?php
    $curDate = date("m/d/Y");
    $url='http://www.mydomain.com/'.$curDate.'.html';
    header('Location:'.$url);
    ?>
    
    PHP:
     
    Rukbat, Oct 29, 2012 IP
  5. xuled

    xuled Banned

    Messages:
    286
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    This is really cool and i think it can will work very nicely.
     
    xuled, Oct 30, 2012 IP
  6. netExelixis

    netExelixis Peon

    Messages:
    10
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Rukbat gave you the solution.
     
    netExelixis, Oct 30, 2012 IP