Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Apache Rewrite - help required.

Options
  • 12-10-2010 9:46am
    #1
    Registered Users Posts: 1,127 ✭✭✭


    Guys

    Im trying to write a pretty URL creator for an online store that Im working on. The idea would be that the URL would look like
    http://shop.com/products/widget/red/1234-XYZ 
    
    Where 1234-XYZ is the product code, and this would rewrite to products.php?param1=1234&param2=XYZ. I understand the pseudo code involved would be something like

    * Get the request URI
    * Write a RewriteCond statement to parse out the 2 parameters into backreferences
    * Take the values of the backreference and add RewriteRule like products.php?param1=$1&param2=$2

    Its the regular expression Im struggling with. How do I find out if the URI ends with a string in that format, ie. 4 numeric, a hyphen and 3 alphanumeric.

    Also, the directory structure could be anything:
    /products/1234-XYZ
    /products/widgets/1234-XYZ
    /products/manufacturer/widget/1234-XYZ
    etc
    

    Any ideas?


Comments

Advertisement