RewriteEngine On
# Map http://www.example.com to /jekyll.
RewriteRule ^$ /jekyll/ [L]
# Map http://www.example.com/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 within jekyll
# This does not expose the internal URL.
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^jekyll/(.*[^/])$ http://www.example.com/$1/ [R=301]
Reference: https://stackoverflow.com/questions/2402140/use-a-subdirectory-as-root-with-htaccess-in-apache-1-3
Leave a Reply