About the .htaccess Generator
The .htaccess Generator runs entirely in your browser — your code and data never leave your machine. Paste, click, copy the result.
The .htaccess file configures Apache web servers (including most shared hosting like Hostinger's default setup) on a per-directory basis — redirects, HTTPS enforcement, custom errors, caching and access rules. A single syntax error can trigger a 500 error for your whole site, so generating known-good snippets beats copy-pasting from old forum posts.
How to use this tool
- Choose the snippet type you need.
- Fill the path/URL fields (redirect, 404, blocking types).
- Generate, copy, and paste into your site's
.htaccessfile in the document root. - Test immediately — if the site 500s, remove the file or the last block to recover.
What each snippet does
| Snippet | Purpose |
|---|---|
| 301 redirect | Permanently move a page — preserves SEO link equity |
| Force HTTPS | Redirect all http:// traffic to https:// |
| Force www | Unify hostname so one canonical version exists |
| Custom 404 | Send visitors to your branded error page |
| Browser caching | Set Cache-Control/Expires so repeat visits load faster |
| Block agent/IP | Deny scrapers or abusive hosts |
| Security headers | X-Frame-Options, XSS-Protection, referrer policy |
Deployment checklist
- Keep a backup of your existing
.htaccessbefore editing. - Add
RewriteEngine Ononce at the top if multiple rewrite blocks exist. - Redirect rules should be before WordPress/other framework rules when SEO-critical.
- After changes, test the URL in an incognito window (browsers cache 301s aggressively).
Who is this tool for?
Hostinger/shared-hosting users managing Apache sites, WordPress admins fixing redirect loops, and developers migrating pages without losing rankings.
Developer tip
After setting up HTTPS, add HSTS only when you're sure every subdomain supports SSL — a wrong HSTS header can lock visitors out for the max-age duration.