.htaccess Generator

Apache Configuration Tool

Online .htaccess Generator

Build common Apache directives without manually writing each rule. Review the generated configuration before placing it in your website's .htaccess file.

Client-side generation Your settings are not submitted to the server.
Configuration

Select the rules you need

Important: A malformed .htaccess file can cause an HTTP 500 error. Keep a backup of your current file before replacing it.
HTTPS and canonical domain Force SSL, www, or non-www
Enter only the domain, without http://, https://, or a path.
Redirects 301 redirects for pages or entire paths
Custom error pages Configure 400, 401, 403, 404, and 500 pages
Directory and file protection Disable listing and protect sensitive files
One filename or filename pattern per line.
Hotlink protection Prevent other websites from embedding your images
Browser caching Set expiration times for static assets
Compression Enable Gzip or Brotli-compatible output rules
Security headers Add common response security headers
Only enable HSTS after confirming the site works completely over HTTPS.
IP access control Allow or deny selected addresses
One IPv4, IPv6, or CIDR range per line.
Use carefully. Allow-listing can lock visitors out.
WordPress hardening Optional rules for WordPress installations
Custom directives Append your own Apache-compatible rules
Only add directives you understand and have tested.