SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    1-800-JMULDER JMulder's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,745
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    RegEx: An Optional Question Mark

    Just writing some RewriteRules for Apache's mod_rewrite and am having loads of problems inserting a piece that makes a question mark optional.

    Code:
    ReWriteRule ^mm(2|3)/([A-Za-z]*)/\??(.*)$ $2/index.php?g=$1&$3 [L]
    Relevant part: \??

    I have tried anything I could think off. Things like [\?]? or whatsoever. I must be overlooking something. Any help would be appreciated since I cannot find the answer on Google or on SitePoint.
    Jeroen Mulder

    w: www.jeroenmulder.com

  2. #2
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    for what I understand you are trying to add the query string to index.php.

    So I'd use:
    Code:
    ReWriteRule ^mm(2|3)/([A-Za-z]+)/ $2/index.php?g=$1 [QSA,L]
    the trick was the QueryStringAppend flag.
    I used + instead of * because i think that the field $2 is obligatory in your requests, using an * you could handle mm2// too.
    It's a choice that you need to evaluate.

    Hope that was what you needed... ;-)


    :-) pippo
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  3. #3
    1-800-JMULDER JMulder's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,745
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're kidding right? That does the trick?

    *tries*

    You're officially my hero. *worship* I should have read more on those flags instead of regex
    Jeroen Mulder

    w: www.jeroenmulder.com


Bookmarks

Posting Permissions

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