Advertisement

.htaccess Generator

Generate a production-ready .htaccess file without memorizing Apache syntax. Force HTTPS, set up redirects, enable caching and compression, then copy or download the file. Free, instant.

.htaccess options

Tick what you need. The file builds itself on the right.

HTTPS and www
Choose one www preference. Leave both unticked for no www rule.
Performance
Security and misc
Your .htaccess

Advertisement

What it generates

A complete .htaccess file for Apache servers: HTTPS and www canonicalization, 301 redirects, GZIP compression, browser caching rules, hotlink protection, directory-listing lockdown, custom 404 and IP blocks. Tick the options you need and the file assembles itself with comments explaining each block.

Copy it or download it, then upload to your site root.

Before you upload

Always back up your existing .htaccess first: one bad rule can take a site down with a 500 error. Upload, then test the homepage, an old redirected URL and an image URL immediately.

Note: these rules are Apache-only. Nginx, Cloudflare Pages and Vercel use different config formats.

.htaccess Generator FAQs

How do I force HTTPS with .htaccess?
Tick Force HTTPS and the generator adds a mod_rewrite rule that 301-redirects every HTTP request to HTTPS. You still need a valid SSL certificate installed for it to work.
Should I force www or non-www?
Either is fine for SEO as long as you pick one consistently. Tick Force www for the www version; leave it unticked and Force HTTPS on for the non-www version.
How do I add a 301 redirect?
Enter one per line as old-path new-url, for example /old-page https://example.com/new-page. Each becomes a Redirect 301 line in the file.
Will this work on Nginx?
No. .htaccess is Apache-only. Nginx uses server blocks in nginx.conf, and hosts like Vercel or Netlify use their own redirect config files.
Why did my site break after uploading?
Almost always a module that is not enabled (like mod_expires) or a syntax slip. Restore your backup, then re-add blocks one at a time to find the culprit.
Advertisement