Getting URL parameters after URL rewriting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mfaisalwarraich
    New Member
    • Oct 2007
    • 194

    Getting URL parameters after URL rewriting

    Hi everyone,

    I have problem while getting the parameters from the URL after some URL rewriting.

    This is my original URL:

    http://www.mysite.com/index.php?page= article-details&id=1

    I am using the following code in my .htaccess file:
    Code:
    RewriteRule    ^articles/([A-Za-z0-9-]+)/?$    index.php?page=article-details&id=$2    [NC,L]    # Process articles requests
    After the above rule my URL becomes:

    http://www.mysite.com/articles/1

    Now in this page im using $_REQUEST['id'] to get the id of the article but im not able to get any value. Please tell me how i can solve this problem.

    Thank you.

    Regards

    Faisal
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Why do you use id=$2 in the target of your RewriteRule? I only see one capture group in your regular expression.

    Try replacing it with id=$1.

    Comment

    • mfaisalwarraich
      New Member
      • Oct 2007
      • 194

      #3
      man it worked. thank you :))

      Comment

      Working...