docs(hosting): add apache config example (#1608)

This commit is contained in:
Jules Kreuer 2024-11-21 01:29:43 +01:00 committed by GitHub
parent 1a4cfa606f
commit a727b57e46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -247,6 +247,28 @@ 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 ### Using Caddy
Here's and example of how to do this with Caddy: Here's and example of how to do this with Caddy: