Developer Tools

.htaccess Generator

Generate .htaccess snippets: 301 redirects, force HTTPS, custom 404, blocking and caching.

Tool

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

  1. Choose the snippet type you need.
  2. Fill the path/URL fields (redirect, 404, blocking types).
  3. Generate, copy, and paste into your site's .htaccess file in the document root.
  4. Test immediately — if the site 500s, remove the file or the last block to recover.

What each snippet does

SnippetPurpose
301 redirectPermanently move a page — preserves SEO link equity
Force HTTPSRedirect all http:// traffic to https://
Force wwwUnify hostname so one canonical version exists
Custom 404Send visitors to your branded error page
Browser cachingSet Cache-Control/Expires so repeat visits load faster
Block agent/IPDeny scrapers or abusive hosts
Security headersX-Frame-Options, XSS-Protection, referrer policy

Deployment checklist

  • Keep a backup of your existing .htaccess before editing.
  • Add RewriteEngine On once 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.

Frequently asked questions

In the document root (public_html) for site-wide rules, or in a subdirectory to scope rules to that folder and below.
Your last .htaccess edit has invalid syntax. Restore the backup or remove the file — Apache will fall back to defaults.
No — Nginx uses server/location blocks. Hostinger offers both Apache and Nginx variants; check hPanel which one your plan uses.

Related tools

Guides for this tool