MagmaNex LogoMagmaNex

.htaccess Generator

Generate Apache .htaccess rules

What does this tool do?

A point-and-click generator that builds an Apache .htaccess file from checkboxes. Add HTTPS redirection, www handling, Gzip compression, browser caching, security headers and more in seconds — perfect for web admins and developers who don't want to memorize rewrite syntax.

How to use it

  1. Enter your configuration details.
  2. Review the generated output.
  3. Copy the ready-to-use code or file.

What you can add

Options include forcing HTTPS with a 301 redirect, adding or removing www, Gzip compression via mod_deflate, browser caching via mod_expires, security headers (X-Content-Type-Options, X-Frame-Options, Referrer-Policy), an index.html fallback for React/SPA routing, image hotlink protection and disabling directory listing. As you tick each box, the real .htaccess output in the text area updates instantly so you can see exactly what each rule produces.

Usage and caveats

Copy the generated code and paste it into the .htaccess file in your site's root directory. If you enable hotlink protection, replace the example 'yourdomain.com' in the output with your actual domain or your own images may be blocked. The add-www and remove-www options are mutually exclusive to avoid redirect loops. Rules rely on mod_deflate, mod_expires and mod_headers; if a module isn't enabled, its <IfModule> block is silently skipped.

Frequently asked questions

Can I use the output as-is?

For most rules, yes. But if hotlink protection is on, change the placeholder 'yourdomain.com' to your real domain, otherwise your own images could be blocked.

Does this work with Nginx?

No. .htaccess is specific to Apache and compatible servers. Nginx uses a separate configuration syntax and ignores .htaccess files.

What does the security headers option add?

It sets X-Content-Type-Options, X-Frame-Options, X-XSS-Protection and Referrer-Policy via mod_headers, giving you baseline protection against common attacks like clickjacking and MIME sniffing.

Is .htaccess Generator free?

Yes. .htaccess Generator and all 300+ tools on MagmaNex are completely free with no signup or account required.

Is my data safe?

Yes. Everything runs locally in your browser. The data you enter is never sent to a server, stored, or shared.

Does it work on mobile?

Yes. .htaccess Generator works on phones, tablets and desktops — no app download needed.

🔒 Privacy: everything runs in your browser, your data is never sent to a server.

Related Tools

📝 Related Articles

Popular Tools