Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    May 2007
    Posts
    108
    Thanks
    19
    Thanked 13 Times in 13 Posts

    mod_rewrite regex help

    Hi guys, I'm wondering if any of you can help me with a mod_rewrite regex.

    I've devised a rule to handle specifying a userid value like: http://domain.com/directory/12345

    Which is: RewriteRule ^([0-9]+)$ ?userid=$1 [L]

    I want to adapt it so that if I need more parameters passed in I can do so using the regular ?var=1&loc=5 way.

    Like this: http://domain.com/directory/12345?var=1&loc=5

    I don't want to do something like this: http://domain.com/directory/12345/var/1/loc/5

    I want to use the question mark and list the values in the standard URL way.

    Thanks so much if you can help! :)

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    You want a query string from the original request to be persisted across to the rewritten address? If so you just need the QSA flag.

    Code:
    RewriteRule ^([0-9]+)$ ?userid=$1 [QSA,L]

  • Users who have thanked Cags for this post:

    >ssp-cdr< (08-07-2011)

  • #3
    Regular Coder
    Join Date
    May 2007
    Posts
    108
    Thanks
    19
    Thanked 13 Times in 13 Posts
    wow that did it! thanks so much


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •