help with mod_rewrite please

Discussion in 'Apache' started by stvwlf, Nov 19, 2009.

  1. #1
    I have a site with old links around the web like this
    http://www.domain.com/blog/archives/990
    and this
    http://domain.com/blog/archives/990

    I need htaccess code to rewrite those old links, both those with and without www, as
    http://www.domain.com/blog/?p=990

    Triggers for the rewrite are the URL's must contain /archives/ and the section after /archives/ must be the last section in URL and must be numeric. That numeric section can be any # of digits long.

    thank you
     
    stvwlf, Nov 19, 2009 IP
  2. reagent

    reagent Active Member

    Messages:
    95
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    68
    #2
    i think about something like this:
    RewriteBase /
    RewriteRule ^.*/archives/(\d+)$ blog/?p=$1 [NC,R=301]
    RewriteCond %{HTTP_HOST} ^domain\.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [NC,R=301]
     
    reagent, Nov 21, 2009 IP