castlegateit/cgit-static-site-template/master/.htaccess - Htaccess File

castlegateit/cgit-static-site-template/master/.htaccess

RewriteEngine On
RewriteBase /

# Options -Indexes

# Set default encoding
AddDefaultCharset UTF-8

# Canonical domain
# RewriteCond %{HTTP_HOST} !^www.example.com [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

# Remove index.php
RewriteRule ^(.*)index.(html|php) $1 [R=301,L]

# Force trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+[^/])$ $1/ [R=301,L]

# Errors
ErrorDocument 403 /403/
ErrorDocument 404 /404/

# Hide source files
RewriteRule ^.git.* - [R=404,L]
RewriteRule ^LICENSE$ - [R=404,L]
RewriteRule ^README.md$ - [R=404,L]

# Remove extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+)/$ $1.php [END]

# Block direct .php access
RewriteRule .php$ - [R=404]

On Github License

Files

Download PDF of Htaccess file
HTTP_HOST, REQUEST_FILENAME

Comments

Apache