.htaccess Generator — Free
Build an Apache .htaccess file with HTTPS redirects, caching, security headers, custom errors, and more. No signup required.
Domain & HTTPS
Performance
Security
PHP
Custom error pages
Custom redirects
No custom redirects. Click + Add to add one.
.htaccess
# Generated by Pixvert .htaccess Generator
# https://pixvert-one.vercel.app/tools/htaccess-generator
# Force HTTPS
# -----------
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
# Directory listing
# -----------------
Options -Indexes
# Custom error pages
# ------------------
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
# 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
AddOutputFilterByType DEFLATE application/json application/ld+json
</IfModule>
# Browser caching (Expires)
# -------------------------
<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 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 day"
</IfModule>
# Security headers
# ----------------
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header always append X-Frame-Options SAMEORIGIN
</IfModule>
# PHP settings
# ------------
<IfModule mod_php.c>
php_value upload_max_filesize 64M
php_value post_max_size 64M
</IfModule>⚡
Performance rules
Gzip compression and browser caching headers speed up page loads automatically.
🔒
Security headers
XSS protection, clickjacking prevention, hotlink blocking and CORS settings in one click.
↪️
Redirects & rewrites
301/302 custom redirects, HTTPS enforcement, and www/non-www canonicalization.