<% site = "http://blogs2.hillandknowlton.com/" appkey = request("appkey") if appkey = "netcoms" then appkey = "digital" end if function redirect(location,perm) if perm = TRUE then ' Response.Status = "301 Moved Permanently" ' Response.AddHeader "Location", location Response.Redirect location else Response.Redirect location end if end function ' home page redirection if request("url") = "" OR request("url") = "/" or request("url") = "/default.aspx" or request("url") = "/about.aspx" or request("url") = "/contact.aspx" or request("url") = "/linklist.aspx" then redirect site & appkey,TRUE response.end end if ' rss feed redirection if request("url") = "/rss.aspx" or request("url") = "/atom.aspx" then redirect site & appkey & "/feed/",TRUE response.end end if ' post redirection if instr(request("url"),"/archive/") then ' it's a post urlarray = split(request("url"),"/") urlyear = urlarray(2) urlmonth = urlarray(3) if urlyear="tags" then redirect site & appkey & "/category/" & urlmonth,TRUE response.end end if if instr(urlmonth,".aspx") then redirect site & appkey & "/" & urlyear & "/" & replace(urlmonth,".aspx","") & "/",TRUE response.end end if if ubound(urlarray)>3 then urlday = urlarray(4) if instr(urlday,".aspx") then redirect site & appkey & "/" & urlyear & "/" & urlmonth & "/" & replace(urlday,".aspx","") & "/",TRUE response.end end if end if if ubound(urlarray)>4 then urlpost = replace(urlarray(5),".aspx","") end if ' troublesome words urlpost = replace(urlpost,"-h-k-","-hk-") urlpost = replace(urlpost,"-s-","s-") urlpost = replace(urlpost,"-m-","m-") urlpost = replace(urlpost,"-t-","t-") urlpost = replace(urlpost,"r-i-p","rip") urlpost = replace(urlpost,"-ing-","ing-") urlpost = replace(urlpost,"-re-","re-") urlpost = replace(urlpost,"-ll-","ll-") urlpost = replace(urlpost,"-nt-","nt-") urlpost = replace(urlpost,"barak","barack") urlpost = replace(urlpost,"-d-c","-dc") ' special post mapping urlpost = replace(urlpost,"flashmobs-are-back-t-mobile-dance-routine-hits-londons-liverpool-station","dancing-girls-and-guys-hit-londons-liverpool-station-for-t-mobile") urlpost = replace(urlpost,"porn-industry-needs-bailout-creative-company-announcements","porn-industry-needs-bailout-creative-company-quotes") urlpost = replace(urlpost,"week-in-events-january-12-18-2008","week-in-events-january-12-18-2009") urlpost = replace(urlpost,"week-in-events-january-5-11-2008","week-in-events-january-5-11-2009") urlpost = replace(urlpost,"d-c-2-0","dc-20") urlpost = replace(urlpost,"what-scrooge-and-bob-cratchit-can-teach-us-about-c-ic","a-lesson-that-even-scrooge-learned") on error resume next urlpostid = cint(urlpost) if err.number<>0 then else urlpost = urlpostid ' lookup the postid in the CS database Set conn = Server.CreateObject("ADODB.Connection") conn.open "Provider=sqloledb;Data Source=localhost;Initial Catalog=CommunityServer;User Id=cs;Password=community;" SQL = "SELECT Subject FROM cs_Posts WHERE (PostID = " & urlpost & ");" Set rs = conn.execute(SQL) ' format the subject line urlpost = lcase(rs("Subject")) urlpost = replace(urlpost," ","-") urlpost = replace(urlpost,"'","") urlpost = replace(urlpost,"&","") urlpost = replace(urlpost,".","") urlpost = replace(urlpost,":","") Set rs = Nothing Set conn = Nothing end if if instr(urlpost,"_") then redirect site & appkey & "/?s=" & lcase(replace(urlpost,"_","+")),FALSE response.end else redirect site & appkey & "/" & urlyear & "/" & urlmonth & "/" & urlday & "/" & urlpost & "/",TRUE response.end end if end if 'article redirection if instr(request("url"),"/articles/") or instr(request("url"),"/pages/") then urlarray = split(request("url"),"/") urlpost = replace(urlarray(ubound(urlarray)),".aspx","") urlpost = replace(urlpost,"_","-") ' troublesome words urlpost = replace(urlpost,"-s-","s-") urlpost = replace(urlpost,"h-k","hk") if instr(urlpost,"_") then redirect site & appkey & "/?s=" & lcase(replace(urlpost,"_","+")),FALSE response.end else redirect site & appkey & "/" & urlpost & "/",TRUE response.end end if end if 'send everything else to the home page redirect site & appkey,FALSE response.end %>