.htaccess Generator
Redirects
Security
Performance
CORS
Custom Redirects
Custom Error Pages
Free .htaccess Generator
Generate properly formatted .htaccess rules for Apache web servers. Configure HTTPS redirects, security headers, caching, GZIP compression, CORS, and custom redirects — all in your browser.
What Is .htaccess?
An .htaccess (hypertext access) file is a configuration file used by Apache web servers. It allows you to set rules for redirects, security, caching, and more on a per-directory basis without modifying the main server configuration.
Common .htaccess Uses
- Force HTTPS — Redirect all HTTP traffic to HTTPS for security
- Security headers — Protect against clickjacking, XSS, and MIME sniffing
- GZIP compression — Reduce file sizes for faster page loads
- Browser caching — Set Expires headers so browsers cache static assets
- Custom redirects — Redirect old URLs to new ones (301/302)
- Custom error pages — Show branded pages for 404, 403, and 500 errors
Security Headers Explained
X-Frame-Options: SAMEORIGIN— Prevents your site from being embedded in iframes (clickjacking protection)X-XSS-Protection: 1; mode=block— Enables the browser's built-in XSS filterX-Content-Type-Options: nosniff— Prevents MIME type sniffing attacksStrict-Transport-Security— Forces browsers to use HTTPS for future visitsReferrer-Policy— Controls how much referrer information is sent
Frequently Asked Questions
Where do I put the .htaccess file?
Upload it to the root directory of your website (the same folder as your index.html or index.php). The rules apply to that directory and all subdirectories.
Does .htaccess work on Nginx?
No. .htaccess files only work on Apache web servers. For Nginx, you need to add equivalent directives to your nginx.conf or site configuration file.
Can .htaccess slow down my site?
Apache reads .htaccess files on every request. For high-traffic sites, it's better to move rules to the main server configuration. For most sites, the performance impact is negligible.