mod rewrite help!

Discussion in 'Programming' started by webvivre, Aug 25, 2006.

  1. #1
    I would like to rewrite the following (example product below)

    /category/group/name-product-12345.html (note: name and 12345 can change)

    to a different directory

    /products/product.php?num=12345

    RewriteRule ([^-]*)-product-([0-9]*).html /products/product.php?num=$1 [L]

    Is it the pathing incorrect or can you not change to another directory?
     
    webvivre, Aug 25, 2006 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    yah - you can have it reading from any directory. Check out my site in my sig - I only have 5 files in the whole site but it looks like thousands of folders to everyone else.
     
    ccoonen, Aug 25, 2006 IP
  3. webvivre

    webvivre Peon

    Messages:
    249
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    But how do you code the rewrite?
     
    webvivre, Aug 26, 2006 IP
  4. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #4
    in your .htaccess:

    RewriteEngine On
    RewriteRule ^category/group/(.*)-product-(.*).html$ /products/product.php?name=$1num=$2

    this should replace your Name to querystring name= and num to the num= all hitting the same page :)
     
    ccoonen, Aug 26, 2006 IP
  5. webvivre

    webvivre Peon

    Messages:
    249
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks - have got it working but it falls over with french accented characters

    How do you add French characters to the rewrite statement?
     
    webvivre, Aug 26, 2006 IP
  6. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #6
    No idea - sorry bro. To remove the "Accented" characters you can convert to Uppercase, then back down to lowercase, this will convert an "ā" to "A" then to "a" if these are the chars you mean?
     
    ccoonen, Aug 26, 2006 IP