301 Redirect Generator
Generate redirect rules for Apache, nginx, Netlify, Vercel and Cloudflare from a mapping.
Build Apache rules for https, www, caching and compression.
A syntax error in .htaccess returns a 500 error for the whole directory rather than being ignored. Keep a copy of your working file before replacing it.
The .htaccess file configures Apache on a per-directory basis, and most shared hosting gives you that file as the only server configuration you control. This generator assembles the rules people actually need, each as a block you can switch on or off, with a comment explaining what it does.
The common blocks are here: force https, choose between www and non-www as the canonical host, set far-future cache headers on static assets, enable gzip or brotli compression, point at custom error pages, block directory listing, protect sensitive files, and add the basic security headers.
One warning worth taking seriously. A syntax error in .htaccess does not degrade gracefully; it returns a 500 error for the whole directory and everything under it. Always keep a copy of the working file before replacing it, and test on staging if you have one. If you control the main server configuration, putting these rules there instead is faster, because .htaccess is re-read on every request.
The .htaccess generator is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:
Apache returns a 500 error for that directory and everything below it, so the site goes down rather than ignoring the bad line. Always keep a copy of the working file before you replace it.
The main configuration is faster, because .htaccess is read on every single request. Use .htaccess when you do not control the server, which is the situation on most shared hosting.
Neither is better for search. What matters is picking one and redirecting the other, so that search engines and analytics see a single canonical host rather than two versions of every page.
No. The syntax is Apache-specific and nginx does not read .htaccess at all. Use the redirect generator's nginx output and put caching and compression directives in your server block.
A year is normal for files with a hash in the name, since a change produces a new filename. For assets whose name never changes, a shorter lifetime avoids serving stale files to returning visitors.
Caching and compression genuinely help, often substantially on a site serving uncompressed assets. They are not a substitute for reducing how much you send in the first place.
If the .htaccess generator is not quite what you need, these other free tools solve closely related problems.
Generate redirect rules for Apache, nginx, Netlify, Vercel and Cloudflare from a mapping.
Generate robots.txt with per-crawler rules, sitemap lines and common presets.
Build security header configuration for Apache, nginx, Netlify or Vercel.
Generate a Content Security Policy header directive by directive, with explanations.
A searchable reference for every HTTP status code, with practical guidance.