Need Mod Rewrite help!

Discussion in 'Apache' started by yo-yo, Jul 17, 2005.

  1. #1
    Page to category:
    mysite.com/products/Accessories.html

    Page to subcategory:
    mysite.com/Accessories/Headphones/3.html

    Page to product:
    mysite.com/product/Sony-Headphones/SPO30.html

    Here's the rule for the product page (works):
    RewriteRule (.*)product/(.+)/(.+).html /showproducts.php?cat=$2&subcat=$3

    Here's the other rule(works for category page):
    RewriteRule (.*)/(.+).html /showproducts.php?cat=$1&subcat=$2

    Now.. I need a rule for the subcategory page... but am unsure how to write it.. heres the dynamic part....

    /showproducts.php?cat=$variable1&subcat=$variable2&page=$variable3

    example: mysite.com/(variable1)/(variable2)/(variable3).html

    Can anyone help? :confused:
     
    yo-yo, Jul 17, 2005 IP
  2. yo-yo

    yo-yo Well-Known Member

    Messages:
    4,619
    Likes Received:
    206
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Even if you don't know the answer.. if you know a better place for me to ask (another forum) just post it or PM me. :p
     
    yo-yo, Jul 17, 2005 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.*)/(.*)/(.*).html$ showproducts.php?cat=$1&subcat=$2&page=$3 [L]
    RewriteRule ^(.*)/(.*).html$ showproducts.php?cat=$1&subcat=$2 [L]
    RewriteRule ^(.*).html$ showproducts.php?cat=$1 [L]

    And make sure you don't have domain.com/index.html or other whatever.html files on the site, or they won't work. (Change .html to .something-else in .htaccess and script if you do have .html static pages.
     
    Nintendo, Jul 18, 2005 IP
  4. yo-yo

    yo-yo Well-Known Member

    Messages:
    4,619
    Likes Received:
    206
    Best Answers:
    0
    Trophy Points:
    185
    #4
    TY ... this looks like what i tried before but in backwards order :D
     
    yo-yo, Jul 18, 2005 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    Right. If you have it in the wrong order, mod_rewrite will freek out!!!!

    Wait, that URL goes to that page. No, to that page. er wait, that page. Bah, I give up. I'll give you nothing.
     
    Nintendo, Jul 18, 2005 IP