Modrewrite Question

Discussion in 'PHP' started by Altari, Aug 17, 2008.

  1. #1
    Can someone tell me (or point me to someplace that tells me) how to make use of GET variables in modrewrite?

    This is totally new territory for me. I basically want to do website.com/cat/cat_name and pull database entries based upon "cat_name".

    Any help would be appreciated.
     
    Altari, Aug 17, 2008 IP
  2. blueribbon

    blueribbon Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use code such as the below in the .htaccess file, basic idea is to use paranthesis in the regular expressions and then use the matched content with $1, $2, $3 etc

    RewriteEngine On
    RewriteRule ^cat/([^-]+)$ cats.php?name=$1 [L,NC,NS]

    Then in your PHP script cats.php the category name will be available in $_REQUEST['name'] using the example above
     
    blueribbon, Aug 17, 2008 IP