Skip to the Main Content

Note:These pages make extensive use of the latest XHTML and CSS Standards. They ought to look great in any standards-compliant modern browser. Unfortunately, they will probably look horrible in older browsers, like Netscape 4.x and IE 4.x. Moreover, many posts use MathML, which is, currently only supported in Mozilla. My best suggestion (and you will thank me when surfing an ever-increasing number of sites on the web which have been crafted to use the new standards) is to upgrade to the latest version of your browser. If that's not possible, consider moving to the Standards-compliant and open-source Mozilla browser.

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   ^(.*)\.html$              $1      [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:   https://golem.ph.utexas.edu/cgi-bin/MT-3.0/dxy-tb.fcgi/19

0 Comments & 0 Trackbacks

Post a New Comment