.htaccess Generator

Generate redirect, HTTPS, caching and security rules for Apache.

Tick the rules you need — the generator writes clean, commented Apache .htaccess code.

⚠️ Always keep a backup of your current .htaccess — a syntax error can take your site offline.

What Does the .htaccess Generator Do?

This generator writes clean, commented Apache .htaccess rules from checkboxes — no need to memorize mod_rewrite syntax. It covers the configurations webmasters need most: force HTTPS, redirect between www and non-www, remove index.php/index.html from URLs, enable GZIP compression and browser caching, block image hotlinking, add security headers, disable directory listings, and define custom 301 redirects line by line.

Every rule block is wrapped in <IfModule> guards, so the file degrades gracefully if a module is missing instead of taking your site down with a 500 error.

How to Generate Your .htaccess

  1. Tick the rules you need; enter your domain for www/hotlink rules.
  2. Add any custom redirects, one per line: /old-page /new-page.
  3. Click Generate .htaccess and review the output — every block is commented.
  4. Download the file and upload it to your site's root directory. Back up your existing .htaccess first.

What the Popular Rules Do

  • Force HTTPS — 301-redirects every http:// request to https://, required once you have an SSL certificate and good for SEO.
  • www vs non-www — picks one canonical hostname and redirects the other, preventing duplicate-content issues.
  • GZIP + caching — compresses text responses and tells browsers to reuse images/CSS/JS for months; the two cheapest speed wins available.
  • Hotlink protection — stops other sites from embedding your images and burning your bandwidth.
  • Security headers — nosniff, frame and referrer policies that harden the site against common attacks.

Frequently Asked Questions

Where does the .htaccess file go?

In the directory it should govern — usually your web root (public_html or htdocs). Rules cascade down into subdirectories. The file name starts with a dot and has no extension.

My site broke after uploading — what now?

Restore your backup (or delete the new file) and the site returns instantly — .htaccess is read on every request, nothing is cached server-side. Then re-add rule blocks one at a time to find the culprit.

Do these rules work on Nginx?

No — .htaccess is Apache-specific (also honored by LiteSpeed). Nginx uses a different config syntax in nginx.conf and ignores .htaccess files entirely.

Should I choose www or non-www?

Either is fine for SEO — what matters is picking one and 301-redirecting the other so search engines see a single canonical version of every URL.