.htaccess Generator
Generate an .htaccess with HTTPS and www redirects, trailing slash rules, Laravel, WordPress or SPA front controllers, blocked dotfiles, caching and compression.
Free · No sign-up · Your inputs stay in your browser
Input
Generate an .htaccess file
Output
.htaccess
1,549 characters
Redirects come before the front controller so each one is a single 301 rather than a chain. Long cache lifetimes are only safe for files whose names change when their content does (app.3f9a1c.js); HTML is sent with no cache. .htaccess is read on every request: on a server you control, the same rules in the vhost are faster.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Order prevents chains
Each redirect costs a round trip, and two in a row (http://www to https://www to https://) waste one. Writing the HTTPS rule to target the final host, and putting all redirects before the front controller, keeps every redirect to a single 301. The RewriteRule flags reference explains L and R.
Block the dotfiles
A .env or .git directory inside the document root is served to anyone who asks for it, and scanners ask constantly. The rule here refuses every path segment starting with a dot except .well-known, which ACME certificate validation and security.txt need.