how to rewrite url using .htaccess file in php, mysql database

Discussion in 'PHP' started by rocket11, Dec 13, 2010.

  1. #1
    Hi Everybody,

    Please tell me how to rewrite url use .htaccess file.

    Actual url is www.mysite.com/index.php?action=pid=11

    i want new url ex: www.mysite.com/productname.html

    Data base table is

    Pid pname pvalue
    1 notebook
    2 iphone

    already i know php with mysql but don't know .htaccess fie and url rewriting.

    Please tell me how rewrite url.


    Thanks & Regards,
    Rockey.
     
    rocket11, Dec 13, 2010 IP
  2. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #2
    it can be done.

    1. you have to add a directive in htaccess to parse html files with php. In that way you can run php code in html files.
    2. Create a php file product.php and pass the "productname"(should be unique) to query mysql database.
    3. Finally, add htaccess rewrite rules

     
    olddocks, Dec 13, 2010 IP
  3. backlinkneeded

    backlinkneeded Member

    Messages:
    285
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #3
    again good little info. thanks olddocks.
     
    backlinkneeded, Dec 22, 2010 IP