blogs and 'virtual directories'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Titus Barik

    blogs and 'virtual directories'

    Hi,

    Throughout the past few years, I've been working on a personal blog
    that I've written using PHP. I recently noticed that a lot of blogs
    support the following URL syntax:

    /archives/2004/04/03/
    /archives/2004/03/
    /archives/2004/

    and so on and so forth. The thing is, they obviously don't have an
    actual HTML or PHP page in that directory; I doubt even that those
    directories actually exist. My guess is that they are doing some sort of
    URL re-writing using .htaccess in combination with perhaps a single PHP
    page that takes in parameters as a GET query. It's just a guess, of
    course.

    The thing is: I really have no idea how they are doing this.

    So, how would I implement something like this on my site using Apache
    and PHP? What is the technical term for this style of 'URL re-writing'
    even called? I don't mind doing a little research on my own, but I can't
    seem to nail down exactly what keywords I need to search for in the
    first place!

    Any pointers or examples would be greatly appreciated.

    Regards,

    --
    titus barik (titus@barik.ne t) | www.barik.net | aim: tbarik
    Italian's windscreens solitude workbench's lecture catering
    steerage's Mercado nuncio's beefed indicting adeptness carped
  • Andy Hassall

    #2
    Re: blogs and 'virtual directories'

    On Sun, 9 May 2004 02:33:34 +0000 (UTC), Titus Barik <titus@barik.ne t> wrote:
    [color=blue]
    >Throughout the past few years, I've been working on a personal blog
    >that I've written using PHP. I recently noticed that a lot of blogs
    >support the following URL syntax:
    >
    >/archives/2004/04/03/
    >/archives/2004/03/
    >/archives/2004/
    >
    >and so on and so forth. The thing is, they obviously don't have an
    >actual HTML or PHP page in that directory; I doubt even that those
    >directories actually exist. My guess is that they are doing some sort of
    >URL re-writing using .htaccess in combination with perhaps a single PHP
    >page that takes in parameters as a GET query. It's just a guess, of
    >course.
    >
    >The thing is: I really have no idea how they are doing this.
    >
    >So, how would I implement something like this on my site using Apache
    >and PHP? What is the technical term for this style of 'URL re-writing'
    >even called? I don't mind doing a little research on my own, but I can't
    >seem to nail down exactly what keywords I need to search for in the
    >first place!
    >
    >Any pointers or examples would be greatly appreciated.[/color]

    Look up 'mod_rewrite' for the Apache implementation of this sort of rewriting.

    e.g. for a format of /archives/2004/04/03/ you may have a rewrite rule such as
    (except all on one line):

    RewriteRule /archives/([0-9]+)/([0-9]+)/([0-9]+)/
    /articles.php?ye ar=$1&month=$2& day=$3

    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

    Comment

    Working...