.htaccess Generator
Generate Apache .htaccess snippets for redirects, HTTPS forcing, caching, compression, and hotlink protection.
Runs entirely in your browser. Nothing is sent to our servers.
About this tool
Generates an Apache .htaccess file from a list of common
requirements. Output is structured with comments so you can see what each
block does and remove pieces you don't need. The generator runs entirely
in your browser — your domain names and redirect lists aren't sent
anywhere.
Where to put it
Place the file at the root of your site (typically public_html
or www). The directives apply to that directory and everything
below it, unless overridden by a deeper .htaccess.
Module requirements
Most directives need specific Apache modules enabled:
- Rewrites (HTTPS, www, redirects, hotlink):
mod_rewrite - Headers (security headers, cache control):
mod_headers - Compression:
mod_deflate - Cache expiry:
mod_expires
Each generated block is wrapped in an <IfModule> check,
so missing modules cause that block to be skipped rather than throwing a
500 error.
Frequently asked questions
- Why did my site break after uploading the .htaccess?
- Almost always one of:
mod_rewritenot enabled (turn it on in cPanel or ask your host);AllowOverrideset to None in the Apache config (only your host can fix that); or a syntax error from manual editing. Remove sections one at a time to bisect. - Should I force HTTPS at the .htaccess level or via the server config?
- If you have access to the main Apache vhost config, do it there for slightly better performance.
.htaccessis fine for shared hosting where you don't have that access. - Does this work with nginx?
- No —
.htaccessis Apache-specific. Nginx uses a different config syntax that lives in the server-level config files, not per-directory files. - What about LiteSpeed?
- LiteSpeed reads
.htaccessfiles for Apache compatibility, so most of these directives work. Some advanced rewrites have edge cases — test your specific config.
Last updated: May 17, 2026