Free .htaccess Generator Online
Generate Apache .htaccess rules for redirects, security headers, caching, compression, and more — without memorizing syntax. 100% client-side — your configuration stays private.
How to Use the .htaccess Generator
- Select common redirects like www/non-www or HTTP/HTTPS normalization.
- Add custom redirect rules with From/To URL pairs for 301 redirects.
- Set directory index files if your server doesn't use default settings.
- Add custom headers for security or caching directives.
- Toggle security and performance options like CORS, gzip, cache control, and hotlink protection.
- Click "Generate", then copy or download the .htaccess file.
Why Use This .htaccess Generator
The .htaccess file is a powerful configuration file for Apache web servers. It controls redirects, security headers, compression, caching, and access rules — but its syntax is notoriously unforgiving.
This generator eliminates syntax errors by building the configuration from your selections. Whether you need a simple HTTPS redirect or a full security hardening setup, this tool produces correct Apache syntax every time.
Frequently Asked Questions
The .htaccess file should be placed in the root directory of your website (the same directory as your public HTML files). Apache reads it on every request.
No. .htaccess is an Apache-specific feature. If you're using Nginx, you'll need to put equivalent rules directly in your Nginx configuration file. This tool generates Apache-compatible syntax only.
Hotlink protection prevents other websites from embedding your images directly. It blocks requests for images that don't originate from your own domain, saving your bandwidth.
Yes. The password protection option generates the necessary AuthType, AuthUserFile, and require directives. You'll still need to create the htpasswd file on your server using the htpasswd utility.
Use Cases
Redirecting Old URLs to New Pages
Create 301 redirects to permanently forward old page URLs to new locations, preserving SEO and user bookmarks.
Blocking IP Addresses with .htaccess
Block specific IP addresses or ranges from accessing your website to prevent unwanted traffic and attacks.
Enabling GZIP Compression
Compress web files before sending them to browsers to reduce bandwidth usage and improve page load speed.
Setting Custom Error Pages
Create custom 404, 500, and other error pages to provide a better user experience when things go wrong.
Protecting Directories with Passwords
Secure sensitive directories with password authentication to restrict access to authorized users only.