Redirect to match old blog entries to new

Discussion in 'Apache' started by slobjones, Nov 30, 2008.

  1. #1
    My old blog listed entries in the format www.mysite.com/?entryid=123.

    The new blog uses www.mysite.com/?p=123.

    How would I redirect the old addresses to new?

    Thanks.
     
    slobjones, Nov 30, 2008 IP
  2. evera

    evera Peon

    Messages:
    283
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    RewriteEngine on 
    RewriteRule ^?p=([0-9]+)$ ?entryid=$1
    Code (markup):
     
    evera, Dec 1, 2008 IP
  3. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #3
    RewriteRule never sees the querystring when it comes to the pattern, only the URI.

    If there's no other GET variables on the querystring, this should work fine assuming all other directives are fine.

    RewriteCond %{QUERY_STRING} ^entryid=([0-9]+)$
    RewriteRule ^/?(.*)$ http://domain.com/$1?p=%1 [R=301]
    Code (markup):
     
    joebert, Dec 2, 2008 IP