DevOps & SysAdmin100% Client-Side Privacy

Apache .htaccess Generator

Generate Apache .htaccess rules for HTTPS redirection, custom 404 pages, gzip caching, and security headers.

Canonical Redirects
WWW Handling:
Security Directives
Performance & Caching
.htaccess

About Apache .htaccess Generator

The Apache .htaccess configuration file controls directory-level directives, URL rewrites, and access controls. Use this tool to generate tested mod_rewrite rules, browser caching directives (mod_expires), and security headers without memorizing intricate Apache syntax.

How to Use This Tool

  1. Select your required rewrite rules (Force HTTPS, Non-WWW to WWW or WWW to Non-WWW).
  2. Toggle security features: Prevent directory listing (Options -Indexes), block sensitive files (.env, .git), and protect against hotlinking.
  3. Set custom error page paths (404, 500) and browser caching headers for web fonts and static images.
  4. Copy the generated directives and save them as '.htaccess' in your web root directory.

Practical Examples & Use Cases

Force HTTPS and Disable Directory Indexing

Expected Output
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Options -Indexes

Enforces 301 permanent redirects to HTTPS and prevents unauthorized directory file browsing.

Frequently Asked Questions

Ensure that 'AllowOverride All' is enabled in your main Apache configuration ('httpd.conf' or 'apache2.conf') for your document root directory.

Related Developer & DevOps Tools