Skip to main content
kitlocal.dev

.htaccess Generator

Runs locally

100% processed in your browser. Inputs and outputs never leave your device.

Generate Apache .htaccess rules for redirects, rewrites, and security

Apache rules

Combine redirects, caching and SPA routing in a downloadable .htaccess file.

Quick setup

Requires Apache 2.4 and the relevant modules with AllowOverride permissions. Test on a staging site. Behind a TLS-terminating proxy, configure trusted HTTPS detection on the server first.

Canonical redirects target the fixed domain above. With Force HTTPS disabled, the current HTTP or HTTPS scheme is preserved. Permanent redirects may be cached by browsers.

.htaccess

# Generated by KitLocal — Apache 2.4; AllowOverride must permit these directives.

RewriteEngine On

# Canonical redirect (fixed host avoids trusting HTTP_HOST).
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/json application/javascript image/svg+xml
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
</IfModule>

<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
26 lines893 bytes.htaccess