htaccess Generator
Professional htaccess Generator
Basic Settings
Performance
Hotlink Protection
Custom Error Pages
Block IP Addresses
Redirects
.htaccess
# Generated by OnDevTools.com
# https://ondevtools.com/en/htaccess-generator
# Follow Symbolic Links
Options +FollowSymLinks
# Disable Directory Listing
Options -Indexes
# Default Charset
AddDefaultCharset UTF-8
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Security Headers
<IfModule mod_headers.c>
Header set X-Content-Type-Options "nosniff"
Header set X-Frame-Options "SAMEORIGIN"
Header set X-XSS-Protection "1; mode=block"
Header set Referrer-Policy "strict-origin-when-cross-origin"
Header set Permissions-Policy "camera=(), microphone=(), geolocation=()"
</IfModule>
# Gzip Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/css text/javascript application/javascript
AddOutputFilterByType DEFLATE application/json application/xml
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
# Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 2592000 seconds"
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
</IfModule>
htaccess Generator
Professional htaccess Generator
Features
- HTTPS redirect (Rewrite rule + 301)
- www / non-www canonicalisation (either direction)
- GZIP / DEFLATE compression block with sensible MIME types
- Browser caching headers (per-type ExpiresByType)
- Custom error documents (404, 500, …)
- Hotlink prevention with regex-escaped referrer matching
- Custom rewrite rules with user-supplied patterns
- Download as .htaccess or copy to clipboard
How to use
- Enter your input data in the provided field.
- Configure any options as needed.
- View the results instantly and copy or download the output.
Tips & Best Practices
- The generated file uses <IfModule> guards so it stays valid even if a module (mod_rewrite, mod_deflate) is missing on your server.
- Order matters — HTTPS redirect should fire before www/non-www canonicalisation. The generator emits them in that order.
- Test the output against your hosting setup before going live; one malformed RewriteRule can take down the entire site.
- For shared hosting with cPanel-style restrictions, only the rewrite + redirect rules are typically allowed.
- Runs entirely in your browser; no config is uploaded anywhere.
FAQ
Is this tool free to use?
Yes, completely free with no registration, no limits, and no hidden costs.
Is my data private?
All processing happens in your browser. No data is ever sent to any server or third party.
Does it work offline?
Once loaded, the tool works entirely offline. All processing is done client-side with JavaScript.
Which browsers are supported?
Works in Chrome, Firefox, Safari, Edge, and all modern browsers on desktop and mobile.
Can I use the results commercially?
Yes, all output is yours to use freely in any personal or commercial project without restrictions.