.htaccess Generator
Build Apache .htaccess rules for HTTPS redirects, caching, GZIP, error pages, and security — with live preview and download.
Custom Error Pages
Live Preview
# URL Rewrites
RewriteEngine On
# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Disable directory browsing
Options -Indexes
# Protect sensitive files
<FilesMatch "(\.env|config\.php)$">
Order Allow,Deny
Deny from all
</FilesMatch>
.htaccess only works on Apache servers — Nginx uses server-block configuration instead.
About .htaccess Generator
Our free .htaccess Generator builds Apache configuration rules with toggles for HTTPS redirect, www handling, custom error pages, browser caching, GZIP, IP blocking, and file protection.
Live preview updates as you toggle rules. Copy to clipboard or download as .htaccess instantly. Inline help explains what each rule does.
No signup, runs entirely in your browser. Note: .htaccess only works on Apache — not Nginx.
Read the full guide: .htaccess file guide 2026 — redirects, caching & security
When Should You Use the .htaccess Generator?
HTTPS migration
Force all HTTP traffic to HTTPS with a permanent 301 redirect.
WWW canonicalization
Choose force www, remove www, or no change.
Performance tuning
Enable browser caching and GZIP compression for static assets.
Custom error pages
Route 404, 403, and 500 errors to branded pages.
Basic security
Block IPs, disable directory listing, protect .env files.
Frequently Asked Questions
What is an .htaccess file?
An .htaccess file is a directory-level configuration file used on Apache web servers. It lets you configure URL redirects, browser caching, GZIP compression, custom error pages, and access controls for a specific directory, without needing to modify the main server configuration.
Does .htaccess work on Nginx?
No — .htaccess is specific to Apache servers. Nginx uses server-block configuration files instead. If your hosting uses Nginx (common on modern cloud hosting), .htaccess rules will be ignored. Check with your host which web server they use.
How do I redirect HTTP to HTTPS using .htaccess?
Add these lines to your .htaccess file: "RewriteEngine On / RewriteCond %{HTTPS} off / RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]". This permanently redirects all HTTP requests to HTTPS using a 301 redirect.
Will incorrect .htaccess rules break my site?
Yes — a syntax error in .htaccess can cause a 500 Internal Server Error for your entire site or directory. Always back up your existing .htaccess before making changes, and test changes on a staging environment first. Most errors come from incorrect RewriteRule syntax or unclosed tags.
Is this generator free?
Yes. WorkUtilities .htaccess Generator is free with no signup.
Help Us Improve
Your feedback helps us build better tools.