# This is ~/web_scripts/.htaccess

# Unicode!
SetEnv LANG en_US.UTF-8

Options +FollowSymLinks

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteBase /

# cgit
# RewriteRule ^gitweb.cgi(/.*)?$ git/gitweb.cgi$1 [L]

# mod_dir will, in combination with the main redirect rule, redirect /some/dir
# to /hugo/some/dir/.  Since we don't want this, we preempt it by adding the
# trailing / ourselves to anything that looks like a directory.
RewriteRule "^((?:.*/)?[^/.]+)$" "/$1/" [R=permanent,END]

# Redirect / to /hugo/ internally.
RewriteRule "^/?$" "/hugo/" [L]

# If it's not an existing file or directory, and we're not trying to access
# /hugo/*, look in /hugo/ internally.
RewriteCond "%{REQUEST_FILENAME}" !-f
RewriteCond "%{REQUEST_FILENAME}" !-d
RewriteCond "%{REQUEST_URI}" !^/hugo/
RewriteRule "^(.*)$" "/hugo/$1"

# Override 404 page to custom script
ErrorDocument 404 /404.py
