About This Tool
The .htaccess file is a per-directory configuration file read by the Apache web server. It lets you control how your website behaves without touching the main server configuration: redirecting visitors, forcing HTTPS, choosing a canonical www or non-www hostname, serving custom error pages, blocking abusive IP addresses, stopping image hotlinking, and enabling browser caching and gzip compression for faster page loads. Writing .htaccess rules by hand is error-prone because a single typo can take an entire site offline with a 500 error. This generator builds correct, well-commented Apache 2.4 syntax for you, entirely in your browser, so nothing you type is ever sent to our server.
How to Use
Enter your primary domain at the top, then flip on the rules you want using the toggles on the left. Each section reveals its own options: choose www or non-www, add as many old-to-new redirect rows as you need with a 301 or 302 status, list IP addresses to block one per line, and so on. As you make changes, the combined .htaccess file rebuilds live on the right with a clear comment header above every section. When it looks right, click Copy to grab it or Download to save a ready-to-upload .htaccess file, then place it in your site document root (usually public_html).
Tips & Best Practices
Always back up your existing .htaccess before replacing it. Test the new file on a staging copy first if you can, because a bad directive returns a 500 error for every page. Force HTTPS and pick a single canonical hostname (www or non-www) so search engines do not treat both versions as duplicate content. Use 301 redirects for permanent moves so link equity passes to the new URL, and 302 only for temporary changes. On Ultra Web Hosting our stack runs NGINX in front of Apache, but Apache still reads and applies your .htaccess normally, so these mod_rewrite redirects and IfModule blocks work as written. If a rule seems to have no effect, confirm the relevant module (mod_rewrite, mod_expires, mod_deflate, mod_headers) is enabled on your server.