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 voodoo!

Discussion in 'Apache' started by dpmis, Oct 20, 2005.

  1. #1
    I have got an articles site.

    I have 2 rewrite rules, 1 for the articles and 1 for the main pages (register, submit etc). Now I need to do one for my caregories. The problem is I want to have the format: /computers/programming/php/ etc, with an infinate number of sub categories.

    the rule will send back to index.php?cat=blah

    Can anyone help me out with a rule for this?

    Cheers
    :)
     
    dpmis, Oct 20, 2005 IP
  2. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could do something like
    RewriteRule ^cat/ /cat_process/myfile.php

    and then in myfile.php do something like
    $path=$_SERVER['REQUEST_URI'];

    for a url like: /cat/computers/programming/php/
    $path = '/cat/computers/programming/php/';

    then you can process your urls in php rather than getting into mod rewrite
     
    stuw, Oct 20, 2005 IP
  3. dpmis

    dpmis Peon

    Messages:
    60
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks mate :)

    I have used that method before, although used forcetype to process a file called dir as a php file. I think I'l prob just stick with that. Just out of interest, can mod_rewrite actually do it on it's own?
     
    dpmis, Oct 21, 2005 IP
  4. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm sure it probably can, I just could never be bothered to find out how, or work put the regex for it....
     
    stuw, Oct 21, 2005 IP