Free Tool

WordPress .htaccess Generator

Free .htaccess generator for WordPress. Generate redirect rules, GZIP compression, browser caching, force HTTPS, block IPs, and security headers — copy and paste ready.

Force HTTPSRedirect all HTTP traffic to HTTPS
GZIP CompressionCompress HTML, CSS, JS — faster page loads
Browser CachingCache images, CSS, JS in visitor's browser
Disable Directory BrowsingPrevent visitors from listing directory contents
Block XML-RPCPrevent brute force attacks via xmlrpc.php
Security HeadersX-Frame-Options, XSS Protection, Referrer-Policy
Prevent Image HotlinkingStop other sites from using your images

What is .htaccess?

The .htaccess file is a server configuration file used by Apache web servers (which host the majority of WordPress sites). It controls URL redirects, security rules, caching, compression, and access control — all without editing the main server config.

For WordPress, the .htaccess file is critical — it handles permalink structure, and is the easiest place to add performance optimizations and security hardening.

Essential .htaccess Rules for WordPress

  • Force HTTPS: Redirect all HTTP traffic to HTTPS — essential for SEO and security
  • GZIP Compression: Compress text-based files by 60-80% — dramatically faster page loads
  • Browser Caching: Tell browsers to cache images and assets — reduces repeat load times by 50%+
  • Block XML-RPC: Prevent brute-force attacks through WordPress's XML-RPC endpoint
  • Disable Directory Browsing: Prevent hackers from viewing your directory structure
  • Security Headers: Add X-Frame-Options, XSS Protection, and other HTTP security headers

Frequently Asked Questions