Dev Tool
Apache .htaccess Generator
Build Apache .htaccess configurations with toggleable sections: redirects, security, GZIP compression, caching, error pages, PHP settings, and SPA routing.
📄Generated .htaccess
# Generated by TinyHub.tools .htaccess Generator
# https://tinyhub.tools/dev-tools/htaccess-generator
# ──────────────────────────────────────
# REDIRECTS
# ──────────────────────────────────────
<IfModule mod_rewrite.c>
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
</IfModule>
# ──────────────────────────────────────
# SECURITY
# ──────────────────────────────────────
# Block directory listing
Options -Indexes
# Block access to sensitive files
<FilesMatch "(\.env|\.git|\.htaccess|\.htpasswd|wp-config\.php|composer\.json|package\.json|\.DS_Store)">
Order allow,deny
Deny from all
</FilesMatch>
# ──────────────────────────────────────
# PERFORMANCE
# ──────────────────────────────────────
# Enable GZIP compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml
AddOutputFilterByType DEFLATE application/javascript application/x-javascript text/javascript
AddOutputFilterByType DEFLATE application/json application/ld+json image/svg+xml
</IfModule>
# Browser caching
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# CSS & JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
# Fonts
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
# Documents
ExpiresByType text/html "access plus 1 hour"
ExpiresByType application/json "access plus 0 seconds"
</IfModule>
# ──────────────────────────────────────
# CUSTOM ERROR PAGES
# ──────────────────────────────────────
ErrorDocument 404 /errors/404.html
ErrorDocument 403 /errors/403.html
ErrorDocument 500 /errors/500.html70 lines