## October 28, 2002

### Monkey See, Monkey Do

In my previous entry, I gave an example of MathML in action. Unfortunately, Mozilla doesn’t recognize that a file contains MathML unless it ends in .xml. A .html file just won’t cut it. It took me a looong time to figure out why I couldn’t see the syntactically-correct MathML rendered in my browser.

Eventually, I just changed all my templates to spit out filenames with extensions .xml, and all was good. But then I had to fool web surfers into downloading files with .xml extensions when they had gotten used to the .html counterparts.

Mod_rewrite to the rescue! I created the following .htaccess file for my blog directory,

# based on example in
# http://httpd.apache.org/docs-2.0/misc/rewriteguide.html
RewriteEngine on
RewriteBase   /~distler/blog/
#   parse out basename, but remember the fact
RewriteRule   ^(.*)\.html1      [C,E=WasHTML:yes]
#   rewrite to document.xml if exists
RewriteCond   %{REQUEST_FILENAME}.xml -f
RewriteRule   ^(.*)1.xml                   [S=1]
#   else reverse the previous basename cutout
RewriteCond   %{ENV:WasHTML}            ^yes$RewriteRule ^(.*)$ \$1.html

deleted all the vestigial .html files, and I was good-to-go.

Posted by distler at October 28, 2002 1:32 AM

TrackBack URL for this Entry:   http://golem.ph.utexas.edu/cgi-bin/MT-3.0/dxy-tb.fcgi/19