1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Mod Rewrite Question

Discussion in 'Apache' started by T0PS3O, Sep 12, 2004.

  1. #1
    I've spent all afternoon and evening reading the literature on apache's rewrite module. Most tutorials are either too basic and most serious papers are too complex IMHO.

    Question: Is the following possible at all?

    For a new project I'd like to use the following URL structure:

    w ww.domain.com/script/category/grandparent/parent/child (not sure on trailing slash here at the end)

    and have it reconverted to:

    w ww.domain.com/script.php?cat=category&grp=grandparent&par=parent&chi=child
    What I've gathered over the last few hours is that it is quite easy yo have it like:

    w ww.domain.com/script/cat/category/grp/grandparent/par/parent/chi/child

    but that is not how I want it.
    Is it possible at all to have it like I want where the rewrite rules basically says: the first dir calls the appropriate php script, the 2nd directory name will be the value of the variable $cat etc. etc.

    Please let me know whether I should continue my research or just stop wanting it my way and rethink my strategy.
    T0PS3O, Sep 12, 2004 IP
  2. arestia

    arestia Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    i too had a hard time when trying to accomplish this on one of my clients sites. we had a structure simular to yours.

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{REQUEST_URI} ^/script/(.*)/(.*)/(.*)/(.*)/
    RewriteRule ^(.*)/ /script\.php?cat=%1&grp=%2&par=%3&chi=%4  [L]
    Code (markup):
    arestia, Sep 12, 2004 IP
  3. T0PS3O

    T0PS3O Feel Good PLC

    Likes Received:
    Best Answers:
    Trophy Points:
    Excellent, I'll try it out!

    Would it allow for empty child or parent variables?

    Like if I want to display all links to available child variables when this page is requested?

    w ww.domain.com/script/category/grandparent/parent/

    Thanks very much though.
    T0PS3O, Sep 13, 2004 IP