php and .htaccess rewrite.

Discussion in 'PHP' started by killaklown, Dec 17, 2007.

  1. #1
    How can I do

    
    if($_GET['category'] == $cat) {
    
    //stuff
    
    }
    
    PHP:
    with .htaccess rewrite on?

    The rewrite is:
    RewriteRule ^category/([^/]+)?$         index.php?category=$cat [QSA,L]
    
    Code (markup):

    I cant seem to get it to work. (never did rewrite before)
     
    killaklown, Dec 17, 2007 IP
  2. hogan_h

    hogan_h Peon

    Messages:
    199
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Did you try this:
    
    RewriteEngine On
    RewriteRule ^category/([^/]+)?$         index.php?category=$1
    
    Code (markup):
    You can call url then with http://www.yourwebsite.com/category/5
    
    if(isset($_GET['category'])) {
    
    echo "Category is: ".$_GET['category'];
    
    }
    PHP:
     
    hogan_h, Dec 17, 2007 IP
    killaklown likes this.
  3. killaklown

    killaklown Well-Known Member

    Messages:
    2,666
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    165
    #3
    thanks. +rep!
     
    killaklown, Dec 18, 2007 IP
    hogan_h likes this.