{
  "$type": "site.standard.document",
  "canonicalUrl": "https://frankhecker.com/2004/11/18/enforcing-canonical-uris-for-blosxom-pages/",
  "path": "/2004/11/18/enforcing-canonical-uris-for-blosxom-pages/",
  "publishedAt": "2004-11-18T11:39:00.000Z",
  "site": "at://did:plc:77mn3ult3b72tpvtqqva6tat/site.standard.publication/3mpfmfpu4u72n",
  "tags": [
    "blosxom"
  ],
  "textContent": "_UPDATE 2023-03-27: This page is obsolete, as it refers to a prior version of this blog.  However, it may be of historical interest._\n\nAs noted in my discussion of [URI rewriting][URI rew], we can use Apache to enforce canonical URI forms for HTML files and directories, but need to use a plugin to enforce canonical forms for URIs handled by Blosxom.  I’ve thus written a new [canonicaluri plugin][canonic] that checks to see whether the requested URI is in the canonical form for the type of page being requested, and if necessary does a browser redirect to the canonical form of the URI.\n\nThe canonical forms are defined as follows:\n\n- URIs for the blog root, categories, and date-based archives should not have an index. component if the flavour being requested is the default flavour (normally “html”), and if an index. component is not present then the URI should have one (and only one) trailing slash.\n- URIs for individual entry pages should not have a trailing slash, and also should not have a flavour extension if the flavour being requested is the default flavour (e.g., “html”).\n\nFor example, if you request either of the URIs\n\n    http://www.example.com/blog/foo\n    http://www.example.com/blog/foo/index.html\n\nwhere “foo” is a category and “html” is the default flavour, this plugin will force a redirect to the canonical URI\n\n    http://www.example.com/blog/foo/\n\nSimilarly, if you request either of the URIs\n\n    http://www.example.com/blog/foo/\n    http://www.example.com/blog/foo.html\n\nwhere “foo” is an individual entry and “html” is the default flavour, this plugin will force a redirect to the canonical URI\n\n    http://www.example.com/blog/foo\n\nNote that this plugin should be used in conjunction with the [extensionless plugin][] and should be configured to run after that plugin, in order to recognize extensionless URIs for individual entries; otherwise redirection will fail for individual entry pages.\n\nAlso note that this plugin depends on the Apache URI rewriting rules to enforce the restriction that a URI should never have more than one trailing slash.  The plugin as presently written can’t handle this case because it depends on the path_info() function to get the URI path, and the path_info() value has already been stripped of any excess trailing slashes that might have been present in the original URI.\n\nSee the [plugin code][] itself for the full documentation.  If you encounter problems with the plugin (or if you just use it and like it) please send me email.\n\n[extensionless plugin]: /blosxom/extensionless\n[plugin code]: /blosxom/plugins/canonicaluri\n[URI rew]: /site/uri-rewriting\n[canonic]: /blosxom/plugins/canonicaluri",
  "title": "Enforcing canonical URIs for Blosxom pages"
}