Free .htaccess File Generator Generator
Secure, Speed Up, and Optimize your Apache server with over 100+ professional configuration options.
1. Domain & URL Redirection
Force HTTPS (SSL)
Redirect all http:// traffic to https://.
WWW Redirect
Choose your preferred domain version.
Trailing Slash
Manage slashes at the end of URLs.
Redirect 301 Generator
Permanently move an old URL to a new one.
2. Advanced Security Headers
HSTS (Strict-Transport-Security)
Prevent downgrade attacks.
X-Frame-Options (Clickjacking)
Prevent your site from being embedded in iframes.
X-XSS-Protection
Enable browser's Cross-Site Scripting filter.
Content Security Policy (CSP)
Basic CSP to prevent XSS (Allow self only).
3. Access Control & Blocking
Block Directory Browsing
Stop users from seeing file lists.
Protect System Files
Block access to .htaccess, .htpasswd, wp-config.php.
Block Specific IP
Ban a user by IP Address.
Referrer Blocking
Block traffic from specific domains (e.g. semalt.com).
Prevent Hotlinking
Stop others from using your images.
4. Performance & Caching
Gzip Compression
Compress HTML, CSS, JS, XML.
Browser Caching (Expires Headers)
Tell browsers to save files locally.
Keep-Alive
Maintain persistent connections.
Disable ETag
Remove ETag header (often helps speed).
5. PHP & Miscellaneous
Increase Upload Limit (php_value)
Set upload_max_filesize to 64M.
Custom Error Pages
Set 404, 500 pages.
CORS Headers
Allow Cross-Origin Access.
Complete .htaccess Cheat Sheet
This tool generates a production-ready .htaccess file. Below is an explanation of the advanced features included.
Security Headers
HSTS: Forces browsers to use HTTPS only.
Clickjacking Protection: Prevents your site from being loaded in an iframe on other sites.
XSS Filter: Enables the browser's built-in script filter.
Performance Tweaks
Gzip: Compresses files before sending them to the user (saves 50-70% bandwidth).
Expires Headers: Tells the browser to cache images and CSS for a month/year, making subsequent visits instant.
Redirects Explained
301 Redirect: Permanent move. Passes SEO "juice" to the new URL.
www vs non-www: Essential for preventing duplicate content issues in Google Search Console.