.htaccess Generator

Generate .htaccess rules for redirects, security headers, and more.

Generate .htaccess rules for redirects, security headers, and more.

Generated .htaccess

# No rules configured.

Generating .htaccess Rules for Apache Servers

Overview

The .htaccess file is a configuration file that controls how an Apache web server handles a directory — redirects, URL rewriting, forcing HTTPS, blocking IPs, custom error pages, and more. Its syntax is terse and easy to get wrong, and a single mistake can take a site down. This generator builds correct .htaccess rules from simple choices so you can apply common server tweaks without memorizing the directives.

How to Use (Step by Step)

  1. 1

    Choose the rules you need

    Select behaviors like force HTTPS, redirect www, or set an error page.

  2. 2

    Review the generated directives

    Check the Apache rules the tool assembled and adjust paths or domains to match your site.

  3. 3

    Save as .htaccess

    Copy the output into a file named .htaccess in the right directory and test the site.

How It Works

You pick the behaviors you want — redirect www to non-www, force HTTPS, set a custom 404 page, block a user-agent, enable caching — and the tool writes the matching Apache directives (RewriteRule, Redirect, ErrorDocument, and so on). You paste the result into a file named .htaccess in your site's directory. Because the rules are just text, the tool assembles them locally in your browser.

When to Use This

Redirecting an old URL to a new one after restructuring a site. Forcing every visitor onto HTTPS. Canonicalizing www vs. non-www or trailing slashes. Setting a custom error page. Blocking a bad bot or IP range. Adding browser caching or compression headers for speed. Password-protecting a directory.

Frequently Asked Questions

In the directory it should affect — usually your site's root for site-wide rules. Rules apply to that folder and its subfolders. The file must be named exactly .htaccess (with the leading dot and no extension).

Important Notes

A syntax error in .htaccess can take down the whole site with a 500 error, so back up the existing file and test after each change. Redirect and rewrite loops are a common trap — verify the final behavior in a browser.

.htaccess Gen | Super Easy Utils