.htaccess Generator
Build Apache .htaccess configuration visually. Add redirects (301/302), URL rewrites, CORS headers, gzip compression, browser caching rules, and custom error pages.
Domain
General
WWW:
Redirects
Error Pages
.htaccess Output
# Generated by The IT Hustle .htaccess Generator
# https://the-it-hustle.com/tools/htaccess-generator
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirects
Redirect 301 /old-page /new-page
# Gzip Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css text/javascript
AddOutputFilterByType DEFLATE application/javascript application/json
AddOutputFilterByType DEFLATE application/xml text/xml
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
# Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 30 days"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/gif "access plus 30 days"
ExpiresByType image/svg+xml "access plus 30 days"
ExpiresByType text/css "access plus 30 days"
ExpiresByType application/javascript "access plus 30 days"
</IfModule>
<IfModule mod_headers.c>
Header set Cache-Control "max-age=2592000, public"
</IfModule>
# Custom Error Pages
ErrorDocument 404 /404.html
# Disable Directory Listing
Options -Indexes
# 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"
</IfModule>Generates Apache .htaccess rules. Always test on a staging server before deploying.