.htaccess / Nginx Config Generator
Tick the rules you need — force HTTPS, redirects, gzip compression, browser caching, security headers, custom error pages — and get ready-to-use config for Apache (.htaccess) or Nginx. Everything generates instantly in your browser.
What is a .htaccess File?
A .htaccess file ("hypertext access") is a configuration file used by the Apache web server that allows directory-level configuration without editing the main server config — useful on shared hosting where you don't have access to the global config. Common uses include forcing HTTPS, setting up redirects, enabling compression, configuring browser caching, adding security headers, and customising error pages. Nginx doesn't use .htaccess files (by design, for performance reasons) — equivalent rules are placed directly in the server's site configuration file.
This tool generates configuration entirely in your browser — nothing is uploaded or sent anywhere.
How to Use This Tool
- Choose your server — Apache (.htaccess) or Nginx — the syntax differs significantly between them.
- Tick the rules you need — force HTTPS, www redirects, gzip compression, caching, security headers, custom error pages, directory listing, and more.
- Fill in any details — some rules need extra info, like your domain name for redirects or which file extensions to compress.
- Copy or download the generated config and add it to your server.
Why These Rules Matter
- Force HTTPS — redirects all HTTP traffic to HTTPS, required for SEO, browser trust indicators, and protecting user data in transit.
- Gzip/Brotli compression — can reduce text-based asset sizes (HTML, CSS, JS) by 60-80%, significantly improving load times.
- Browser caching — tells browsers to reuse static assets (images, CSS, fonts) instead of re-downloading them on every visit.
- Security headers — headers like
X-Frame-Options,X-Content-Type-Options, andContent-Security-Policyprotect against clickjacking, MIME-sniffing attacks, and XSS. - Custom error pages — branded 404/500 pages improve user experience when something goes wrong.
Frequently Asked Questions
AllowOverride is set to None in the main Apache configuration for that directory — .htaccess files are completely ignored unless AllowOverride All (or specific directives) is enabled. Other causes: the required Apache module (mod_rewrite, mod_deflate, mod_expires, mod_headers) isn't enabled, or there's a syntax error causing a 500 Internal Server Error — check your server's error log for details.sudo a2enmod rewrite then restart Apache with sudo systemctl restart apache2. On shared hosting, mod_rewrite is almost always already enabled — if rewrite rules aren't working, the issue is more likely AllowOverride or a syntax error in your rules.sudo nginx -t to test for syntax errors, then sudo systemctl reload nginx to apply changes without dropping active connections.Content-Security-Policy (CSP) and X-Frame-Options. CSP can block inline scripts, external fonts, or third-party widgets (analytics, chat widgets, embedded videos) if they're not explicitly allowed in the policy. X-Frame-Options can break legitimate iframe embeds of your site. Test thoroughly after adding security headers, starting with report-only modes for CSP where supported.