Generate .htaccess files for Apache servers with HTTPS, caching, redirects and more.
Advertisement
# Generated by ToolPile .htaccess Generator
# https://toolpile.co/htaccess-generator
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Enable Gzip Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript text/xml application/xml
AddOutputFilterByType DEFLATE 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/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>
# Custom Error Pages
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
Advertisement
Generate .htaccess Files
Create properly formatted .htaccess files for Apache servers. Configure HTTPS redirection, www preference, Gzip compression, browser caching, hotlink protection, custom error pages, 301/302 redirects and IP blocking. Download the file and upload it to your server root directory.