⚙️

.htaccess Generator

Build Apache .htaccess rules for redirects, HTTPS enforcement, cache control, hotlink protection and custom error pages. Copy-ready output. Free, browser-based.

💻 Developer Tools Free Browser-based
Tool

Enable the sections you need, configure the options, then click Generate.

Force HTTPS Redirect all HTTP → HTTPS

Redirects every HTTP request to the secure HTTPS equivalent using a 301 permanent redirect.

WWW Redirect Force www or non-www
Custom Redirect 301 or 302 redirect a path
Browser Caching Cache static assets
Hotlink Protection Block image leeching
Custom Error Pages 404, 403, 500
Disable Directory Listing Hide folder contents

Prevents Apache from showing a list of files when no index file is present in a directory.

What Is .htaccess?

An .htaccess file is a per-directory configuration file for the Apache web server. It overrides the main server config for requests within that directory tree, allowing you to set up redirects, authentication, caching headers and security rules without restarting the server.

Common Use Cases

RulePurpose
Force HTTPSRedirect all HTTP traffic to secure HTTPS
WWW redirectCanonicalise domain to www or non-www
Browser cachingTell browsers to cache CSS/JS/images locally
Hotlink protectionBlock other sites from embedding your images
Custom error pagesShow branded 404/403/500 pages
Disable directory listingPrevent visitors from browsing your file tree

Important Notes

Apache must have AllowOverride All set in its virtual host config for .htaccess files to take effect. Also ensure mod_rewrite is enabled (a2enmod rewrite on Debian/Ubuntu). Always back up your existing .htaccess before overwriting it.

Frequently Asked Questions