Skip to main content
Linux & System Administration Tools

Apache .htaccess Generator

Generate common Apache .htaccess rules - HTTPS redirect, www/non-www redirect, caching, compression, and security headers.

Select the rules you need - HTTPS redirect, www handling, caching, compression, security headers - this tool assembles a clean .htaccess file.

For the equivalent rules on an Nginx server instead of Apache, see the Nginx Redirect Generator.

What Is a .htaccess File?

A .htaccess file lets Apache apply configuration - redirects, caching rules, security headers, and more - at the directory level, without editing the main server configuration.

Why Use This Tool?

.htaccess directives (mod_rewrite rules especially) have a terse, easy-to-mistype syntax where a small error can silently fail or, worse, create a redirect loop. This tool generates correct, common rule blocks.

How to Use It

  1. Select the rules you need: force HTTPS, redirect www to non-www (or the reverse), enable browser caching, enable compression, or add common security headers.
  2. Copy the generated .htaccess content into your site's root directory.

Limitations

.htaccess only works on Apache servers with AllowOverride enabled for the relevant directives - always test redirects carefully (in a private/incognito window) to avoid a cached redirect loop.

Frequently Asked Questions

Apache only reads .htaccess if AllowOverride is enabled for the directory, and rewrite rules need mod_rewrite. Ask your host if you are on shared hosting.

In your website's document root (for Laravel, the public folder). Rules apply to that folder and everything below it.

No. Nginx does not read .htaccess files - the rules must be converted into the Nginx server configuration.
Share this tool: