Apache .htaccess Generator
Generate common Apache .htaccess rules — HTTPS redirects, caching, Gzip, custom error pages, and more.
Options
WWW handling
604800 = 1 week, 2592000 = 30 days, 31536000 = 1 year
Output
# Generated by zeroserver.tools — Apache .htaccess Generator
Options +FollowSymLinks
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Custom 404 error page
ErrorDocument 404 /404.html
# Disable directory listing
Options -Indexes
# Enable Gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/css text/javascript application/javascript
AddOutputFilterByType DEFLATE application/json application/xml application/xhtml+xml
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
# Browser cache headers
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 604800 seconds"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
Header set Cache-Control "max-age=604800, public"
</IfModule>
About Apache .htaccess Generator
The .htaccessfile is Apache's per-directory configuration file. It lets you set redirects, authentication, custom error pages, URL rewriting, compression, and cache headers without modifying the main server config. This generator produces rules using mod_rewrite, mod_deflate, and mod_expires — all standard Apache modules.
Private & free — this tool runs entirely in your browser.
Recommended: Cloudways — Managed cloud hosting on AWS, GCP & DO — from $11/mo.affiliate
Related Generators tools
UUID Generator
Generate secure v4 UUIDs.
QR Code Generator
Create customizable QR codes and export as SVG or PNG.
Lorem Ipsum
Generate placeholder paragraphs, sentences, or word lists.
Random Hex Generator
Generate cryptographically random hexadecimal strings.
Random Number String
Generate a random string of digits of any length.
Random String Generator
Generate random strings from a custom character set.
Random Color Generator
Generate random colors as HEX, RGB, and HSL.
MAC Address Generator
Generate random MAC addresses in several formats.