Free .htaccess Generator
Generate Apache .htaccess rules without memorizing mod_rewrite syntax. Toggle HTTPS enforcement, www handling, trailing slashes, and hotlink protection, add custom 301 redirects, and copy a clean, commented config file ready to upload.
Generated .htaccess
How to Use the Htaccess Generator
- Toggle the rules you need: HTTPS, www preference, trailing slash, directory listing.
- Add custom 301 redirects as old-path ⇒ new-URL lines.
- Set an optional custom 404 page and hotlink protection.
- Click Copy .htaccess or download the file, then upload it to your site root.
Features
The builder covers the most-used .htaccess tasks: force-HTTPS rewrites, www/non-www canonicalization, trailing-slash enforcement, custom 301 redirect lists, ErrorDocument 404 pages, Options -Indexes to hide directory listings, and image hotlink protection with your domain allowlisted. Output is commented section by section so you can audit every rule before deploying.
Benefits & Use Cases
Site owners migrating pages set up SEO-safe 301 redirects without touching regex; bloggers force HTTPS in one step; anyone hardening a shared host disables directory browsing and hotlinking in minutes. The generated syntax follows Apache best practices, avoiding the common RewriteRule mistakes that cause redirect loops.
Tips
Test rules on a staging site first — a bad rewrite can take a site offline; keep a backup of your existing .htaccess. Remember .htaccess only works on Apache (and LiteSpeed); Nginx users need server-block config instead.
Frequently Asked Questions
What is an .htaccess file?
A configuration file for Apache web servers. Placed in a directory, it controls redirects, access rules, error pages, and other server behavior for that directory without editing the main server config.
What is the difference between a 301 and 302 redirect?
A 301 is permanent: browsers and search engines transfer ranking signals to the new URL. A 302 is temporary. For moved pages, migrations, and www/HTTPS canonicalization, use 301.
Will these rules work on Nginx?
No. Nginx does not read .htaccess files — equivalent rules must go in the Nginx server block configuration. This generator targets Apache and compatible servers like LiteSpeed.
Why did my site break after uploading .htaccess?
The usual causes are a syntax error, a redirect loop (e.g. conflicting www rules), or mod_rewrite not being enabled. Restore your backup and add rules back one section at a time.
Where do I upload the .htaccess file?
Upload it to the directory it should apply to — usually the website’s document root (public_html or www). Rules also affect subdirectories unless overridden.
Related Tools
Robots.txt Generator
Generate robots.txt files visually with NToolHub’s free tool. Allow/disallow rules, sitemap reference, crawl delay — copy-ready.
Open tool →Sitemap Generator
Generate XML sitemaps free with NToolHub. Paste URLs, set priority and change frequency — valid sitemap.xml in seconds, 100% private.
Open tool →URL Encode
Percent-encode URLs and text instantly with NToolHub’s free tool. Component or full-URL mode, UTF-8 safe — private in-browser.
Open tool →Meta Tag Generator
Generate SEO and social meta tags with NToolHub’s free tool. Title, description, Open Graph, Twitter cards — copy-ready HTML head code.
Open tool →URL Decode
Decode percent-encoded URLs instantly with NToolHub’s free tool. Handles UTF-8, plus-as-space, batch lines — private in-browser.
Open tool →