Last Updated: February 25, 2016
·
349
· nsteiner

Enable Mixture URLs in Apache

This is useful if you use Mixture (http://mixture.io/) and want to use the convert-html feature without using Mixture's relative-pathing option. In your Mixture config for the site you'd turn off relative paths (which can be time consuming to process for very large sites):

"convertHtml": {
  "relativePaths": false
},

Then for your server, here a ruleset you can put in your .htacess file which will render urls that don't have an extension as their .html counterparts.

Options +FollowSymLinks -Indexes -MultiViews
RewriteEngine On
# If no trailing slash or "." in URL
RewriteCond $1 !(/$|\.)
# and if URL with appended slash does NOT exist as a directory
RewriteCond %{DOCUMENT_ROOT}/$1/ !-d
# and if page DOES exist with ".html" appended
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
# then append ".html" to URL
RewriteRule ^(.+?)/?$ /$1.html [R=301,L]