Advanced .htaccess Generator
Generate Apache rewrite, redirect, security, caching, compression, and performance rules instantly without writing code. Free, mobile-friendly, no signup — copy or download a production-ready .htaccess in seconds.
http:// to https:// using a 301 permanent redirect. Required for SEO and modern browsers.www.example.com → example.com. Pick this OR the next option, not both.example.com → www.example.com./about → /about/. Helps canonicalize URLs./about/ → /about.Add unlimited 301/302 redirects. Use paths like /old-page → /new-page or full URLs.
htpasswd -c /full/path/to/.htpasswd username on your server. Store it OUTSIDE your web root.
Compression
mod_brotli on the server.Browser Caching
Leave blank to skip a particular error page.
Access-Control-Allow-Origin headers so other domains can fetch your fonts, APIs, or assets from JavaScript.Tell Apache how to serve modern file formats.
Any Apache directives entered here are appended verbatim to the generated file.
1
# Click "Generate" to build your .htaccess
Generate the file to see a plain-English explanation of every directive.
How It Works
The Advanced .htaccess Generator turns plain-English choices into production-ready Apache configuration. Pick the rules you need, hit Generate, then copy or download the file.
Pick Your Rules
Expand any section and tick the options you want — HTTPS, redirects, security, caching, and more.
Generate Instantly
The right-hand panel updates with a live, syntax-highlighted preview of your .htaccess.
Copy or Download
One-click copy to clipboard, or download a ready-to-upload .htaccess file.
Upload & Test
Back up your current file, upload the new one to your site's root via FTP/cPanel, then test in an incognito window.
.htaccess before replacing it. A single typo can cause a 500 Internal Server Error.
Frequently Asked Questions
What is an .htaccess file?
An .htaccess file is a per-directory configuration file used by Apache web servers. It lets you control URL rewriting, redirects, access control, caching, compression, and security headers without editing the main server config.
How do redirects work in .htaccess?
Redirects use the mod_rewrite or mod_alias module. A 301 tells browsers and search engines a URL has permanently moved (passes SEO value). A 302 is temporary. The generator outputs the correct directive based on your choice.
How do I force HTTPS using .htaccess?
Tick Force HTTPS. The generator outputs a RewriteCond %{HTTPS} off followed by a 301 RewriteRule that redirects every request to the https:// version of the same URL.
What is hotlink protection?
It blocks other websites from embedding your images directly from your server (which wastes your bandwidth). The generated rules allow only your domains, and optionally return a custom replacement image.
What is browser caching?
Caching headers tell visitors' browsers to store static assets (images, CSS, JS, fonts) locally for a defined period, dramatically speeding up repeat visits and reducing server load.
Can incorrect .htaccess rules break my website?
Yes. A syntax error or a missing Apache module can cause a 500 Internal Server Error and take your site offline. Always back up the existing file before replacing it.
How do I restore my previous .htaccess configuration?
Rename your backup (e.g. .htaccess.bak) back to .htaccess via FTP, SSH, or your hosting file manager. Your site will return to its previous state immediately.
Is this tool free?
Yes — the .htaccess generator runs entirely in your browser, requires no signup, and is 100% free.
Does GZIP or Brotli require server support?
Yes. GZIP needs mod_deflate and Brotli needs mod_brotli. The directives are wrapped in <IfModule> blocks so they fail silently if the module isn't enabled.
Related Developer Tools
Explore more free webmaster & developer utilities on FastSaveMedia: