.htaccess Generator
Generate Apache .htaccess configuration files with redirects, caching, compression, and security headers.
🔒 Basic Settings
🌐 WWW Preference
⏱️ Cache Expiry
↪️ URL Redirects
→
🚫 Custom Error Pages
# Generated by Repo - .htaccess Generator
# https://repo.pk
# Enable Rewrite Engine
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Custom Redirects
Redirect 301 /old-page /new-page
# GZIP Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css
AddOutputFilterByType DEFLATE text/javascript application/javascript
AddOutputFilterByType DEFLATE application/json application/xml
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
# Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/webp "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>
# 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"
Header set Permissions-Policy "geolocation=(), microphone=(), camera=()"
</IfModule>
# Custom Error Pages
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
Features
- URL redirects (301/302)
- GZIP compression
- Browser caching
- Force HTTPS
- Security headers
- Hotlink protection
How to Use
- 1Configure your settings
- 2Add custom redirects
- 3Copy the generated code
- 4Paste into your .htaccess file
Frequently Asked Questions
Where do I put this file?
Place .htaccess in your website's root directory (public_html or www folder).
Will this break my site?
Always backup your existing .htaccess first. Test changes on a staging site if possible.