⚙️ .htaccess Generator

Toggle the options you need and get a ready-to-use .htaccess file with live preview, copy and download.

Redirects & URLs
Force HTTPS Redirect all HTTP traffic to HTTPS
Force www Redirect non-www to www
Remove www Redirect www to non-www
Add trailing slash Redirect /page to /page/
Performance
Enable Gzip Compression Compress HTML, CSS, JS, JSON, fonts
Browser Caching Cache static assets (images, CSS, JS)
Disable ETags Remove ETags for better caching
Security
X-Frame-Options Prevent clickjacking (SAMEORIGIN)
HSTS Header Strict Transport Security (1 year)
X-XSS-Protection Enable browser XSS filter
X-Content-Type-Options Prevent MIME type sniffing
Referrer-Policy Set strict-origin-when-cross-origin
Disable Directory Listing Prevent browsing directory contents
Block Sensitive Files Block .env, .git, composer files
Prevent Hotlinking Block other sites from hotlinking images
CORS & Errors
Enable CORS Allow cross-origin requests
Custom Error Pages 404 → /404.html, 500 → /500.html
Live Preview

        

What is an .htaccess file?

An .htaccess file is a directory-level configuration file used by Apache web servers. It allows you to configure server behaviour like redirects, authentication, caching, and security headers without modifying the main server config.

Force HTTPS redirect

The HTTPS redirect rule uses mod_rewrite to catch all HTTP requests and permanently redirect them (301) to the HTTPS equivalent. This ensures all traffic is encrypted.

Gzip compression

Enabling mod_deflate compresses text-based responses before sending them to the browser, reducing transfer size by 60–80% for HTML, CSS, and JavaScript files.

Security headers

Headers like X-Frame-Options, X-Content-Type-Options, and HSTS protect against common web vulnerabilities. X-Frame-Options prevents your site from being loaded in an iframe on other domains, protecting against clickjacking attacks.

Browser caching

Setting Expires and Cache-Control headers for static assets tells browsers to cache them locally, reducing repeat load times. CSS/JS files are typically cached for 1 year; HTML pages for 1 day.

🧾 Need to extract data from invoice PDFs? Try our Invoice Extractor — paste a PDF, get structured data instantly.

Try Invoice Extractor →