more mod_rewrite help

Discussion in 'Apache' started by esiason14, Dec 21, 2006.

  1. #1
    I've tried searching the forums, but just cant seem to get this to work

    I want to rewrite url's like this:
    http://www.whatever.com/historical_pts.php?year=2006&position=4&week=2
    Code (markup):
    to this:
    http://www.whatever.com/historical_pts/year/2006/position/4/week/2
    Code (markup):
    Note: the week variable is optional, so I have to take that into acct.

    Any help would be appreciated! Thanks
     
    esiason14, Dec 21, 2006 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    If you havn't seen it yet, check the sticky thread!

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^historical_pts/year/([^.]+)/position/([^.]+)/week/([^.]+)$ historical_pts.php?year=$1&position=$2&week=$3 [L]
     
    Nintendo, Dec 21, 2006 IP
    esiason14 likes this.
  3. esiason14

    esiason14 Peon

    Messages:
    272
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, Nintendo...I'll check it out. One more question. As for the [L]. I'm assuming that means the last line, correct? I have other rewrites within the same htaccess, so does the [L] go at the very end...or should it appear after each rewrite?
     
    esiason14, Dec 21, 2006 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    # 'last|L' (last rule)
    Stop the rewriting process here and don't apply any more rewriting rules. This corresponds to the Perl last command or the break command from the C language. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the root-path URL ('/') to a real one, e.g., '/e/www/'.
    # 'next|N' (next round)

    Apache site has them on each of them.
     
    Nintendo, Dec 21, 2006 IP
  5. esiason14

    esiason14 Peon

    Messages:
    272
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks again, Nintendo. I got it working...now I have to go back and change the way my other links are displaying...other than that it's perfect!
     
    esiason14, Dec 21, 2006 IP