Help with Mod Rewrite - Willing to Pay :)

Discussion in 'PHP' started by yaffiliate, Mar 20, 2007.

  1. #1
    I need help with the mod rewrite code for my site FastestCar.com. I want to replace the dynamic page extensions. So, when someone goes to a category page it appears as http://www.fastestcar.com/bmw/ not http://www.fastestcar.com/index.php?101010225 and when someone goes to a specific vehicle page it appears as http://www.fastestcar.com/BMW/1996-M3 not http://www.fastestcar.com/index.php?13103169225.

    Thanks...
     
    yaffiliate, Mar 20, 2007 IP
  2. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #2
    I can help, it may involve a small change to your PHP script but I can do it.

    No worries about payment [unless you really want to] it shouldn't take too long

    PM me for more info or post here so other people can learn!
     
    m0nkeymafia, Mar 20, 2007 IP
  3. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #3
    In fact i managed to dig out some of my old code pretty quickly.

    Basically you will need to have your URL like so:

    fastestcar.com/make/modelnumber/yourid
    i.e.
    fastestcar.com/bmw/x-5/1101011

    and then use this in your htaccess

    RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([0-9]+)/$ /index.php?showcar=$3

    That will pass the last argument [the ID number] to your index.php. Note that it will only match URLs that are text/text/number.

    If you wish to omit the number then pass in a different argument [$1 is the first, $2 is the second and so forth] to your script and do a text based query to find the right car.

    i.e.

    RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ /index.php?car_make=$1&car_model=$2

    select car_make, car_model from cars where car_make={$_GET['car_make']} and car_model = {$_GET['car_model']}

    Also make sure your urls remove any crazy characers like "£$%"£&^ etc and also replace spaces with hyphens "-"
     
    m0nkeymafia, Mar 20, 2007 IP