public
Last active

Insane mod_rewrite gymnastics for my blog setup.

  • Download Gist
.htaccess
ApacheConf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
RewriteEngine On
 
# Map http://henrik.nyh.se to /jekyll.
RewriteRule ^$ /jekyll/ [L]
 
# Map http://henrik.nyh.se/x to /jekyll/x unless there is a x in the web root.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/jekyll/
RewriteRule ^(.*)$ /jekyll/$1
 
# Add trailing slash to directories without them so DirectoryIndex works.
# This does not expose the internal URL.
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} !/$
RewriteRule ^(.*)$ $1/
jekyll/.htaccess
ApacheConf
1 2 3 4
# Disable auto-adding slashes to directories without them, since this happens
# after mod_rewrite and exposes the rewritten internal URL, e.g. turning
# http://henrik.nyh.se/about into http://henrik.nyh.se/jekyll/about.
DirectorySlash off

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.