Boneyard Tools

.htaccess Generator

Generate a clean Apache .htaccess without memorizing the syntax. Flip on the rules you need, like forcing HTTPS, a www redirect, custom 301s or blocked IPs, and copy the file straight into your site root.

How to generate an .htaccess file

  1. Toggle the rules you want, such as force HTTPS, a www mode or caching.
  2. Add any custom redirects, blocked IP addresses or error pages.
  3. Copy the output or download the .htaccess file into your site root.

Examples

Force HTTPS and redirect an old page

forceHttps: true, redirect /old to /new (301)
# === Rewrite engine ===
RewriteEngine On

# === Force HTTPS ===
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

# === Custom redirects ===
Redirect 301 /old /new

Block an IP and set a 404 page

blockIps: [203.0.113.5], errorPages: [404 -> /404.html]
# === Block IP addresses ===
<RequireAll>
    Require all granted
    Require not ip 203.0.113.5
</RequireAll>

# === Custom error pages ===
ErrorDocument 404 /404.html

Frequently asked questions

What is an .htaccess file?

It is a per-directory configuration file for the Apache web server. You drop it in a folder to change how Apache handles requests there, for example to add redirects, block visitors or set caching, without editing the main server config.

Where do I put the .htaccess file?

Save it as a file named exactly .htaccess (with the leading dot and no extension) in the folder you want it to affect, usually the web root such as public_html. Rules apply to that folder and everything below it.

Why is my .htaccess being ignored?

Apache only reads .htaccess when AllowOverride is enabled for the directory and the relevant modules are loaded. Forcing HTTPS or www needs mod_rewrite, caching needs mod_expires, and compression needs mod_deflate. The blocks here are wrapped in IfModule so they fail safe if a module is missing.

Will this work on Nginx?

No. The .htaccess format is specific to Apache and compatible servers like LiteSpeed. Nginx does not read .htaccess files, so you would translate these rules into your server block instead.

What is the difference between a 301 and a 302 redirect?

A 301 is permanent and passes ranking signals to the new URL, so use it for moves that will stick. A 302 is temporary and tells browsers and search engines the original URL will return, so it does not pass the same authority.

Is my data sent to a server?

No. The file is generated entirely in your browser from the options you toggle, so nothing you type is uploaded anywhere.

Related tools