mod_rewrite question

Discussion in 'Apache' started by Darkhodge, Apr 19, 2007.

  1. #1
    Hi,


    I want to have this sort of structure for showing category / subcategory pages:

    http://www.domain.com/categoryName/page1.html
    http://www.domain.com/categoryName/subCatName/page1.html

    Is there any way I can make these point to utilize different php files? If I use anything like:

    
    RewriteRule ^(.*)/page(.*)\.html$ catPage.php?catName=$1&page=$2 [L]
    RewriteRule ^(.*)/(.*)/page(.*)\.html$ subCatPage.php?catName=$1&subCatName=$2&page=$3 [L]
    
    Code (markup):
    It won't work because it takes the whole of "categoryName/subCatName" as the catName variable...

    I'm not actually very experienced with mod_rewrites but would this problem be solved by using regex? Like changing the (.*) to ([^/]*)?


    Thanks,

    Hodge :)
     
    Darkhodge, Apr 19, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There's only one way to find out - try it! ;)

    But yes, that change to the regex pattern should sort you out.
     
    rodney88, Apr 19, 2007 IP
  3. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #3
    Agreed - but I only thought of it after I posted the original post, so I decided to edit the post and ask rather than testing it out first. :)
     
    Darkhodge, Apr 19, 2007 IP