# do not mess with the subdomains # (I’ve named them with folders starting with “_”) RewriteEngine on RewriteRule ^_ - [L] DirectorySlash off DirectoryIndex index.html index.cgi # this ‘feature’ drove me absolutely insane! # without this, Apache will give a 404 for a rewrite if a folder of the same name does not exist (e.g. “/blog/hello”) # Options -MultiViews +Indexes # allow you guys to see this file allow from all # error messages: ErrorDocument 404 /404 # additional filetypes # -------------------------------------------------------------------------------------------------------------------------- # HTML5 video / audio: AddType video/ogg .ogv AddType audio/ogg .oga AddType video/mp4 .mp4 AddType text/html .html5 # .html5 files are gzipped HTML documents ready to serve AddType text/css .csz # gzip’d CSS file AddType font/ttf .ttf .ttz # `@font-face` font embedding. I’ve gzip’d fonts into a “ttz” filetype too AddType image/svg+xml .svg .svz # SVG file (used for SVG fonts), “svz” gzip’d SVG file AddType application/rss+xml .rsz # gzip’d RSS file AddType text/xml .xmz # gzip’d XML sitemap # compressed cache AddEncoding gzip .html5 .csz .ttz .svz .rsz .xmz # force utf-8 for a number of file formats: AddDefaultCharset utf-8 AddCharset utf-8 .rem .html5 .css .csz .rsz .js # caching # -------------------------------------------------------------------------------------------------------------------------- FileETag MTime Size ExpiresActive on ExpiresDefault "access plus 24 hours" ExpiresByType text/html "access plus 1 hour" ExpiresByType application/rss+xml "access plus 1 hour" ExpiresByType image/png "access plus 1 week" ExpiresByType image/jpg "access plus 1 week" ExpiresByType image/jpeg "access plus 1 week" ExpiresByType video/ogg "access plus 1 week" ExpiresByType audio/ogg "access plus 1 week" ExpiresByType video/mp4 "access plus 1 week" ExpiresByType image/x-icon "access plus 3 months" ExpiresByType font/ttf "access plus 3 months" ExpiresByType image/svg+xml "access plus 3 months" # to seperate content / code webroot is pure content, and the site’s code / design is all within ‘/.system/’ RewriteRule ^robots.txt$ /.system/robots.txt [NC,L] RewriteRule ^favicon.ico$ /.system/design/favicon.ico [NC,L] RewriteRule ^apple-touch-icon.png$ /.system/design/apple-touch-icon.png [L] RewriteRule ^sitemap$ /.system/sitemap.xmz [L] # mistakes: I make a lot of them, these are here to correct them. move along, nothing to see here... # ========================================================================================================================== # should not have used a period in the folder names for the old verisons of the site RewriteRule ^code/files/0\.(\d)(.*)$ /code/archive/0_$1$2 [R=301,L] # for a brief period the RSS was mapped as "/rss/" instead of "//rss" and this change has plagued me # since. despite sending 301 (permenant redirection), some readers don't update themselves accordingly RewriteRule ^rss/([a-z0-9-]+)?$ /$1/rss [R=301,L] # chose a bad name for the remarkable folder that didn’t match the case of the article RewriteRule ^code/(?:files/)?ReMarkable/(.*)$ /code/remarkable/$1 [R=301,L] # ========================================================================================================================== # legacy: corrections for how previous versions of the website worked, you can ignore this... # ========================================================================================================================== # I changed the ‘tweet’ section to ‘quote’ RewriteRule ^tweet/(.*)$ /quote/$1 [R=301,L] # links to the HTML used to be ‘.xhtml’ files, now ‘.html5’ because I dropped XML RewriteRule ^(.*)\.xhtml$ /$1.html5 [R=301,L] # support files for articles were held in a folder called 'files', but are now held in a folder with the same name as the # article. e.g. ‘/code/video_for_everybody’ is the article, and ‘/code/video_for_everybody/’ is the folder with images &c. RewriteRule ^([-a-z]+)/files/(.*)?$ /$1/$2 [R=301,L] # don’t have page numbers anymore RewriteRule ^([a-z0-9-]+/)?\d{1,2}$ /$1 [R=301,L] # redirect the old source code pages to the archive (v0.1) RewriteRule ^code/(code|content|database|shared)\.php /code/archive/0_1/$1.php [R=301,L] # tannerhelland.com used to be hosted here RewriteRule ^System/RSS/TannerHelland/(News|MusicReleases).xml$ http://www.tannerhelland.com/feed/ [R=301,NC,L] RewriteRule ^TannerHelland/.*$ http://tannerhelland.com/ [R=301,NC,L] # theraje.com was temporarily in a subfolder, now in a subdomain RewriteRule ^(?:theraje.php)$ http://theraje.camendesign.com [R=301,NC,L] # put any querystring through index.php (legacy v0.1 URL redirector) RewriteCond %{QUERY_STRING} .+ RewriteCond %{REQUEST_URI} ^/$ RewriteRule ^ /.system/legacy.php [L] # ========================================================================================================================== # compressed CSS / RSS # -------------------------------------------------------------------------------------------------------------------------- # use the compressed CSS if in cache, if not, cache it RewriteCond %{REQUEST_URI} ^/design/$ RewriteCond %{DOCUMENT_ROOT}/.cache/design.csz -F RewriteRule ^design/$ /.cache/design.csz [L] RewriteRule ^design/$ /.system/article.php?article=.system/design/design.css [L] RewriteRule ^design/(.*)$ /.system/design/$1 [L] # give the compressed RSS file for the given directory # if the file exists in the cache use that, if not, pass to the PHP to generate RewriteCond %{REQUEST_URI} ^/([a-z0-9-]+/)?rss$ RewriteCond %{DOCUMENT_ROOT}/.cache/%1rss.rsz -F RewriteRule ^([a-z0-9-]+/)?rss$ /.cache/$1rss.rsz [L] RewriteRule ^(?:([a-z0-9-]+)/)?rss$ /.system/rss.php?category=$1 [L] # PHP source # -------------------------------------------------------------------------------------------------------------------------- # you can view the source of all the PHP files on the site due to the distinction that no PHP files are called directly by # name in the site, instead all PHP is executed via some kind of RewriteRule. therefore we make it that any direct visit to # a PHP file shows in plain text, but rewrites execute the PHP instead RewriteRule ^php$ /.system/ [L,R] # any direct request for a PHP file will return the source code: # unfortunately this does not work when running PHP as a CGI module, we use ‘view-source.php’ instead RewriteCond %{THE_REQUEST} \.php(\?.*)?\ HTTP RewriteRule ^.*(?