From fb3fbacc86a956d26d741b51926ab2588a8c960f Mon Sep 17 00:00:00 2001 From: Jules Kreuer <25013642+not-a-feature@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:34:57 +0100 Subject: [PATCH] Add apache config example to hosting.md --- docs/hosting.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/hosting.md b/docs/hosting.md index eaeea19b2..33a4635a1 100644 --- a/docs/hosting.md +++ b/docs/hosting.md @@ -246,6 +246,25 @@ server { } } ``` +### Using Apache +Here's an example of how to do this with Apache: + +```apache title=".htaccess" +RewriteEngine On + +ErrorDocument 404 /404.html + +# Rewrite rule for .html extension removal (with directory check) +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI}.html -f +RewriteRule ^(.*)$ $1.html [L] + +# Handle directory requests explicitly +RewriteCond %{REQUEST_FILENAME} -d +RewriteRule ^(.*)/$ $1/index.html [L] +``` +Don't forget to activate brotli / gzip compression. ### Using Caddy