Developer Utilities · Free tool
.htaccess Generator
Generate Apache .htaccess with HTTPS redirect, Gzip, caching, error pages, hotlink protection, 301 redirects.
Updated May 2026
# .htaccess generated by Free Tool Arena
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Custom redirects
Redirect 301 /old-url /new-url
# Enable Gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json image/svg+xml
</IfModule>
# Browser caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 hour"
</IfModule>
# Custom error pages
ErrorDocument 404 /404.html
ErrorDocument 500 /500.htmlApache-only. Save as .htaccess in your site root. Test in a staging environment before pushing live — a misformatted .htaccess can take a site down (500 errors). For Nginx, the equivalent goes in your server block, not a per-directory file.
Found this useful?Email
Advertisement
What it does
Generate an Apache .htaccess file with common configurations: HTTPS redirect, www/non-www enforcement, Gzip, browser caching, custom error pages, hotlink protection, and 301 redirects.
Embed this tool on your siteShow snippetHide
Paste this snippet into any page. Loads on-demand (lazy), no tracking scripts, and sized to most dashboards. Replace the height to fit your layout.
<iframe src="https://freetoolarena.com/embed/htaccess-generator" width="100%" height="720" frameborder="0" loading="lazy" title=".htaccess Generator" style="border:1px solid #e2e8f0;border-radius:12px;max-width:720px;"></iframe>How to use it
- Tick the features you want enabled.
- For redirects, type 'old-url new-url' one per line.
- Copy and save as .htaccess in your site root.
- Test in staging — a misformatted .htaccess can take a site down (500 errors).
Frequently asked questions
- Does this work for Nginx?
- No — .htaccess is Apache-specific. For Nginx, the equivalent rules go in your server block in nginx.conf. The intent is the same; the syntax differs.
Advertisement
Learn more
Guides about this topic
- Using Our Tools · GuideHow to generate QR codesMake a QR code for a URL, wifi, vCard, or plain text. What error-correction means, how big to print, how to test it.
- Using Our Tools · GuideHow to create a strong passwordThe entropy math, 2026 NIST rules, passphrases vs passwords, password managers, MFA and hardware keys, where passkeys fit, 5 mistakes that still lose accounts
- Developers & Technical · GuideHow to encode and decode Base64What Base64 is (not encryption), the 3-to-4 encoding mechanics, standard vs URL-safe vs MIME variants, 33% overhead, when to use it, common mistakes
- Design & Media · GuideHow to choose a color paletteHSL color theory, four palette schemes (monochromatic, analogous, complementary, triadic), the 60-30-10 rule, WCAG contrast, dark mode, and palette tools.
- Developers & Technical · GuideHow to use JWT tokens securelyJWT anatomy, HS256 vs RS256, the 'alg: none' attack, expiration strategy, storage (localStorage vs httpOnly cookies), revocation patterns, and claim validation.
- Design & Media · GuideHow to design a faviconThe sizes you actually need in 2026, design principles that survive 16×16 rendering, dark mode support, the HTML tags, web manifest, and testing.
Explore more developer utilities tools
- Color Palette ExtractorExtract dominant colors from any image. Histogram-based, runs in browser. Click swatches to copy hex.
- JavaScript MinifierStrips comments and collapses whitespace from JS. For production minification, use terser or esbuild.
- HTML Table GeneratorInteractive HTML table builder. Click cells to edit. Toggle headers, stripes, borders. Inline-styled output for emails.
- CSS Button GeneratorVisual CSS button generator. Hover, active, and focus-visible states baked in. Tunable colors and sizing.
- CSS Animation GeneratorVisual CSS @keyframes animation builder. 8 presets with customizable duration, delay, easing, iterations.
- JSON VisualizerInteractive tree view of any JSON document. Click to expand/collapse nodes. Useful for exploring API responses.