.htaccess Generator
Build Apache .htaccess rules visually — redirects, HTTPS, caching, CORS, and more.
Security & Redirects
Performance
Access Control
Custom Error Pages
Redirects
No redirects added yet.
What Is .htaccess?
.htaccess is a per-directory configuration file for the Apache web server. It lets you override server settings for a specific directory without editing the main server config. Common uses include URL redirects, HTTPS enforcement, access control, custom error pages, and performance optimizations like GZIP and browser caching.
How to Use
- Toggle the rules you want to enable.
- Configure any options (cache duration, CORS origin, error pages).
- Add custom redirects in the Redirects section.
- Copy the generated
.htaccesscontent and place it in your web root.
Key Features
- Force HTTPS with a permanent 301 redirect
- Add or remove www prefix
- GZIP compression for text assets
- Browser caching with configurable expiry
- Hotlink protection for images
- CORS headers with custom allowed origin
- Custom 404 and 500 error pages
- Multiple 301/302 redirects
FAQ
Does .htaccess work on Nginx?
No. .htaccess is Apache-specific. For Nginx, you need to configure rules in the server block inside nginx.conf or a site config file.
Where do I place the .htaccess file?
Place it in the directory you want to configure — usually the web root (public_html or www). Rules apply to that directory and all subdirectories.
Can I combine Force HTTPS with Force/Remove www?
Yes. Enable both — the generator places the HTTPS rule first, then the www rule, which is the correct order to avoid redirect loops.