The end of forte.sun.com and RewriteRule voodoo
`` Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo. ''
-- Brian Moore, bem@news.cmc.net
It is often said that it is a lot easier to launch a site than to EOL it. I have to say I haven't seen an exception to this statement yet. forte.sun.com was the first site I worked on. In the late fall of 2000, after tiring of QA'ing products, I took a leap into the unknown and signed up to be the engineering manager for the "Forte for Java Portal". What a marvellous sense of timing I had, to be working on something new in the web space as the dotcoms started imploding all around me. My promised staff of six turned into three contractors. My budget diminished every quarter. But we launched it and it was a success. We had a tight team and had a lot of fun.
It wasn't just an HTML site, it had several applications. For example, the Update Center. This feature was a non-HTML service that provided XML catalogs directly to the product (Sun Java Studio ... formerly known as Forte for Java). It was kind of a non-standard webservice, before such a term was coined.
So I guess it was only fitting, that I ended up working on it's demise. The Update Center has been replaced by another update system. Most of the forte.sun.com content had moved over a year ago to developers.sun.com, it took that long to get the new update system functional and the catalogs moved over. My piece of this should have been small, the machine serving forte.sun.com had been turned over to IT management, so all I needed to do was just log a ticket to get the redirects put in place and then check that everything worked. Or so I thought.
The problem was, that we needed to update the redirects in an Apache server. You see, we don't have very many instances of Apache here at Sun. About 2 years ago, we really started to eat our own dogfood. So Apache is not well known here. And so they asked me to help.
Ok, I thought no problem, I can figure this out, the mod_rewrite module is already being loaded (all those content redirects) so how hard can it be? So I googled away and the first thing I saw was the voodoo quote. Hmmm.
You see I didn't just want to do a redirect, I wanted the redirect to tack the original query string on the end of the target's URL query string. So I came up with (I've shortened the URLs for brevity):
RewriteRule ^/ffjcatalog(.*) http://www.sun.com/applink?sundispatcher=1.0.2&REDIR$1 [R,NE,L]
Problem was that the redirect worked, but it lost the query string. The next thing I tried was:
RewriteRule ^/ffjcatalog\?(.*) http://www.sun.com/applink?sundispatcher=1.0.2&REDIR&$1 [R,NE,L]
The problem with this is that the rewrite rule didn't get triggered. That should have tipped me off there, that mod_rewrite was doing something special with the query string... because it should have matched, but I didn't have a lot of confidence in my knowledge of regular expressions so I went on trying all sorts of permutations. It wasn't until I read through the RewriteCond doc that it finally dawned on me that the query string was being put into a variable I could use. Here's what worked.
RewriteRule ^/ffjcatalog$ http://www.sun.com/applink?sundispatcher=1.0.2&REDIR&%{QUERY_STRING} [R,NE,L]
These old sites, they don't take EOL'ing too kindly, they fight it until their last dying breath.
Over here at MLB, we also (you may have heard) eat a lot of Sun's "dogfood"... (and quite tasty dogfood it is... we're pouring gravy on our new E15K and savoring every bite)...
HOWEVER! I sorely miss the rewrite capabilities and flexibility of Apache... we're currently looking into writing in-house a simple rewrite/redirect engine (that takes a simple config file) in NSAPI, or commissioning one from someone, and I swear, I'll campaign to release it to the world for free... maybe Sun'll include it in the sunone nsapi examples dir.
Posted by Ryan Nelson on December 02, 2004 at 07:28 PM PST #