.htaccess Generator
Build Apache .htaccess redirects, caching and security rules with conflict checks
Errors: 0 · Warnings: 0 · Redirects: 0
Related Tools
What it generates
The generator writes an Apache 2.4 .htaccess file for common redirect, performance and security needs: force HTTPS, one canonical host, trailing-slash and index.html clean-up, custom 301/302/307/308 redirects, gzip compression, Expires caching presets, directory-listing and dotfile protection, basic security headers, optional HSTS and custom error pages. Every section has an inline comment, and the order is always the same so diffs stay readable.
Conflict checks
Before a redirect is written, it is checked for malformed sources, unsafe or unexpected destination protocols, duplicates, self-redirects, A to B to A loops and chains that cost an extra hop. Rules that would loop or never run are left out of the file and listed under Findings. Canonical host and trailing-slash options are single choices, so contradictory rules such as add www and remove www cannot be combined.
Apache details that matter
All rewrite rules share one IfModule mod_rewrite block with a single RewriteEngine On. HTTPS and host changes happen in one redirect, trailing-slash rules skip real files and folders, and slash or index redirects apply only to GET and HEAD requests. Access control uses Require all denied, never the obsolete Order and Deny syntax. Module-dependent blocks are wrapped in IfModule, so a missing module skips a block silently instead of breaking the site.
Before you deploy
.htaccess works only where the server AllowOverride setting allows these directives; otherwise Apache answers 500. Place the file in the document root, because custom redirect paths are relative to it. Behind a proxy or CDN that terminates TLS, the HTTPS rule cannot see the original scheme and may loop. Enable HSTS only after HTTPS works everywhere, starting with a short max-age. Browsers save the download as htaccess.txt; rename it to .htaccess on the server. Everything runs in your browser and nothing is uploaded.
