current date html file with mod_rewrite

Discussion in 'Site & Server Administration' started by bumbar, Oct 22, 2012.

  1. #1
    Hello!

    how it looked .htaccess file to get this

    mysite.com/22-10-2012.html
    mysite.com/31-12-2012.html
    mysite.com/01-12-2012.html

    and so on ...

    All files comes from index.php file like this index.php?date=22-10-2012

    Thank you!
     
    Last edited: Oct 22, 2012
    bumbar, Oct 22, 2012 IP
  2. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #2
    You could do something like this:
    
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^([0-9]+)-([0-9]+)-([0-9]+)\.html$ /index.php?date=$1-$2-$3 [L]
    
    Code (markup):
     
    Last edited: Oct 22, 2012
    pr0t0n, Oct 22, 2012 IP
  3. badolfus

    badolfus Greenhorn

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    8
    #3
    The mod_rewrite rule for your site is done. Please follow the instructions below to install it.

    1. First you need to check if the file .htaccess exists in the root of your website.
    2. If the file .htaccess exists, download it from your site, add the lines below to the end of the file, and upload the modified file back to your site. Please make a copy of the original file .htaccess. So if anything goes wrong, you may restore the original file.
    3. If the file .htaccess does not exist, create a new file .htaccess and add the lines below to it. Then upload it to the root of your website. You may delete it if anything goes wrong.
    Add the following lines to .htaccess:
    RewriteEngine On
    RewriteRule ^([^/]*)\.html$ /?date=$1 [L]
     
    badolfus, Oct 26, 2012 IP