.htaccess Generator
Generate .htaccess rules for HTTPS redirects, www handling, caching and more.
Generate .htaccess rules for HTTPS redirects, www handling, caching and more.
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Custom redirects
Redirect 301 /old-page /new-page
Redirect 301 /blog/* /news/$1
# Custom error pages
ErrorDocument 404 /404.html
# Gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json
</IfModule>
# Browser caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
</IfModule>