{"id":109,"date":"2002-11-23T12:59:54-05:00","date_gmt":"2002-11-23T20:59:54+00:00","guid":{"rendered":"http:\/\/peterjanes.ca\/wordpress\/?p=109"},"modified":"2002-11-23T12:59:54-05:00","modified_gmt":"2002-11-23T20:59:54+00:00","slug":"baby-steps","status":"publish","type":"post","link":"https:\/\/peterjanes.ca\/blog\/2002\/11\/23\/baby-steps\/","title":{"rendered":"Baby&nbsp;steps"},"content":{"rendered":"<div class='e-content'><p>Mark Pilgrim has <a href=\"http:\/\/diveintomark.org\/archives\/2002\/11\/21.html#a_warning_to_others\">updated his site<\/a> based on <a href=\"http:\/\/ln.hixie.ch\/?start=1037595583&amp;count=1\">recommendations<\/a> from Ian Hickson on <a href=\"http:\/\/ln.hixie.ch\/?start=1037202166&amp;count=1\">building a perfect Web log<\/a>.  Following some of their lead, I&#8217;ve added the first bit of browser checking to my site using <a href=\"http:\/\/httpd.apache.org\/\">Apache&#8217;s<\/a> <code>mod_rewrite<\/code>.  The module has always scared me, but using what amounts to an identity rewrite I&#8217;ve managed to dynamically change the MIME type returned for my weblog pages.  Here&#8217;s how it works.<\/p>\n\n<pre>RewriteEngine on<\/pre>\n\n<p>This line turns on the rewriting engine for the current directory and all subdirectories below it.<\/p>\n\n<pre>RewriteCond %{HTTP_USER_AGENT} ^Mozilla\/[5-9].* [OR]\nRewriteCond %{HTTP_USER_AGENT} ^Amaya\/[5-9].*<\/pre>\n\n<p>These two lines define the conditions where the following rule will apply.  They look at the <code>HTTP_USER_AGENT<\/code> variable (i.e. the <code>User-Agent:<\/code> field in the HTTP request) and check that it begins with <code>Mozilla\/<\/code> or <code>Amaya\/<\/code> followed by a major revision that is known or presumed to support the correct MIME type for XHTML files.  (I&#8217;m working under the assumption that if it&#8217;s supported in an earlier version it will continue to be supported in a later one.)<\/p>\n\n<pre>RewriteRule ^(.*)\\.html$ - [T=application\/xhtml+xml]<\/pre>\n\n<p>Finally, I add the rule itself: any file that has the extension <code>.html<\/code> gets mapped to exactly the same name.  By itself that&#8217;s useless and just wastes cycles on each request&#8230; except for the <code>T=<\/code> field that resets the MIME type, which was the original goal.<\/p>\n\n<p><a href=\"http:\/\/www.foodtv.com\/tvshows\/nakedchefslangdictionary\/\">Easy peasy.<\/a><\/p>\n\n<p>Right now, all of these lines are in a .htaccess file in the weblog directory.  If\/when I update the rest of the site to a version of XHTML (most of it has been, but I&#8217;m not confident enough to switch completely yet), these rules will migrate to my global httpd.conf.<\/p><\/div><div class=\"syndication-links\"><\/div>","protected":false},"excerpt":{"rendered":"Mark Pilgrim has updated his site based on recommendations from Ian Hickson on building a perfect Web log. Following some of their lead, I&#8217;ve added the first bit of browser checking to my site using Apache&#8217;s mod_rewrite. The module has always scared me, but using what amounts to an identity rewrite I&#8217;ve managed to dynamically&hellip;","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"mf2_syndication":[],"venue_id":0},"categories":[3],"tags":[],"kind":false,"_links":{"self":[{"href":"https:\/\/peterjanes.ca\/blog\/wp-json\/wp\/v2\/posts\/109"}],"collection":[{"href":"https:\/\/peterjanes.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peterjanes.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peterjanes.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peterjanes.ca\/blog\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":0,"href":"https:\/\/peterjanes.ca\/blog\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"wp:attachment":[{"href":"https:\/\/peterjanes.ca\/blog\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peterjanes.ca\/blog\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peterjanes.ca\/blog\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}