.htaccess Generator

Easily create configuration files for Apache web servers.

.htaccess Generator

Generate a production-ready Apache .htaccess file — every block explained inline.

General

Used in hotlink allow-lists and the file header.

Redirect rules (301 / 302)

Security

Performance

Images
CSS / JS
Fonts
HTML

Hardening & errors

AddDefaultCharset UTF-8 for all responses.
ServerSignature Off — remove Apache version banner.
FileETag None — remove ETag headers.
400
401
403
404
500
503

Generated .htaccess84 lines · 10 blocks

Lint: no issues found — blocks balanced, directives known.

What each block does

Canonical URLs (HTTPS / WWW / trailing slash)
Redirects every HTTP request to the HTTPS version with a permanent 301.
Redirect rules (1)
Each rule maps an old path to a new one with a 301 status code — use 301 for permanent moves, 302 for temporary ones.
Block bad bots (18 user-agents)
Returns 403 to known scraper bots and any custom user-agent patterns you added.
Security headers
Sets 6 HTTP response headers that harden the site against clickjacking, MIME sniffing and data theft.
Block sensitive files
Returns 403 for .htaccess, .env, .git, log files and SQL dumps.
Browser caching (mod_expires)
Tells browsers how long to cache each content type: Images=1y, CSS / JS=1M, Fonts=1y, HTML=0.
GZip compression (mod_deflate)
Compresses HTML, CSS, JS, JSON, XML and fonts before sending — smaller downloads, faster pages.
Server hardening
UTF-8 charset, No server signature.
Custom error pages (6 codes)
Serves your own HTML pages for HTTP error codes instead of the default Apache page.
Prevent directory browsing
Options -Indexes — visitors get 403 instead of a file listing when no index file exists.
Infinio Tools
© 2026 Infinio Labs