Developer tool
.htaccess Generator
Free, no sign-up. Runs in your browser; nothing is uploaded.
Options
.htaccess
The result appears here.
How to use the .htaccess generator
Build the file
- Tick the features you need. The preview on the right updates as you go.
- Fill in the text boxes: one redirect per line as
/old-path /new-path, one error page per line as404 /404.html, and one IP address or range per line. - Press Copy or Download, then upload the file as
.htaccessto your site root. - Test in a private window and with a header checker before you tell anyone it is live.
What the options do
- Force HTTPS sends every plain HTTP request to the secure address with a permanent 301. It also respects
X-Forwarded-Proto, which matters behind a proxy or CDN. - www handling picks one canonical host. Choosing one and redirecting the other avoids duplicate pages in search results.
- Compression and caching shrink transfers and let browsers keep static files for a long time. Use file names with a version or hash when you cache for a year, so updates reach visitors.
- Security headers add basic protections against content sniffing, framing and referrer leaks. Add a Content-Security-Policy with the CSP generator when you are ready.
- File protection blocks dot files and common leftovers such as
.env, backups and SQL dumps.
Safe ways to deploy
Keep a copy of the working file before replacing it, and change one thing at a time. If your site breaks, restore the old file from FTP or the host's file manager. WordPress and similar systems write their own block of rules to .htaccess: paste new rules above or below that block and leave it intact.
Frequently asked questions
Where do I put the .htaccess file?
Place it in the folder it should apply to, normally the web root such as public_html. Rules also apply to every subfolder unless a deeper .htaccess overrides them. The name starts with a dot, so enable hidden files in your FTP client.
My site shows a 500 error after uploading it. What now?
A directive probably needs a module your host has not enabled, or AllowOverride is off. The generated blocks are wrapped in IfModule checks where possible. Remove sections one at a time to find the cause, and read the Apache error log.
Does this work on nginx?
No. nginx ignores .htaccess files. Use the nginx config generator on this site for the same rules.
Should I use Redirect 301 or a rewrite rule?
Redirect 301 is simple and fine for single paths. Use rewrite rules for patterns, protocol and host changes. The tool uses each where it fits best.
Is anything stored or sent?
No. The file is built in your browser from the options you choose.