Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Apache Rewrite - help required.

  • 12-10-2010 09:46AM
    #1
    Registered Users, Registered Users 2 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