.htaccess mod_rewrite get variables not working

Discussion in 'Apache' started by TAJ, Sep 7, 2013.

  1. #1
    Hi,
    I'm trying to rewrite the urls across a site I'm developing, which pass get variables like the following:
    localhost/link/link1/page.php?id=12
    would look like:
    localhost/page/12

    The first link in the htaccess file works fine, but the following ones don't (whatever the order, the first one works). Can anyone tell me why/help me solve it please?

    I'm attaching a snippet of the file here:
    
    # http://localhost/html/content_quiz/quiz-results.php?quizid={number}
    # to
    # http://localhost/results/quiz/{number}
    RewriteRule ^results/quiz/([0-9]+)/?$ /html/content_quiz/quiz-results.php?quizid=$2 [NC,L]
    
    # http://localhost/html/content_pages/results.php
    # to
    # http://localhost/results
    RewriteRule ^results/?$ /html/content_pages/results.php [NC,L]
    
    # http://localhost/html/content_quiz/grade.php?quizid={number}
    # to
    # http://localhost/quiz/{number}/grade
    RewriteRule ^quiz/([0-9]+)/grade/?$ /html/content_quiz/grade.php?quizid=$3 [NC,L]
    
    Code (markup):
    At the moment, it goes up to $6, but more will be added later on in development.
     
    TAJ, Sep 7, 2013 IP
  2. TAJ

    TAJ Greenhorn

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    I managed to get it working. It seems that I needed to leave $1 for all of them. I guess it's because it only executed the one line before ending?
     
    TAJ, Sep 7, 2013 IP