.htaccess Builder
Select the rules you need and configure them below. The builder generates ready-to-paste Apache .htaccess code. Runs entirely in your browser.
100% client-side · no upload
Select rules
Custom redirect
Block IP address
Enable GZIP compression
Compress HTML, CSS, JS, XML, fonts
CORS headers
Deny access to hidden files
Block .env, .git, .htpasswd, etc.
How to use the .htaccess Builder
- Check each rule you want to include.
- Fill in any required fields (IP, redirect paths, CORS origin).
- The output updates automatically in the right panel.
- Click Copy and save the result as
.htaccessin your web root. - Test with
apachectl -tor by visiting your site — check Apache error logs if rules don't fire.
Related tools: NGINX Config Formatter · SSL Cert Decoder · DNS Record Builder · All DevOps Tools
Preguntas frecuentes
- What is an .htaccess file?
- An .htaccess file is a directory-level Apache configuration file. It overrides the main server config for that directory, allowing per-site rules for redirects, authentication, access control, and HTTP headers without touching the main httpd.conf.
- Does .htaccess work on NGINX?
- No. .htaccess is Apache-only. For NGINX, use a server {} block in your nginx.conf. This builder generates Apache-compatible rules only.
- Is .htaccess performance-optimal?
- .htaccess is processed on every request, which has a small performance cost compared to main-server config. For high-traffic sites, move rules to the main Apache config (VirtualHost block) and disable AllowOverride. .htaccess is ideal for shared hosting where you cannot edit the main config.
- How do I force HTTPS on all pages?
- Select the "Force HTTPS" rule. It uses RewriteCond to check for a non-HTTPS request and redirects with a 301 (permanent) to the https:// version of the URL.
- What is the difference between 301 and 302 redirects?
- A 301 is a permanent redirect: browsers and search engines remember it and update their records. A 302 is temporary: search engines keep indexing the original URL. Use 301 for domain changes or canonical URL fixes, and 302 for temporary campaigns.
- Can I combine multiple rules?
- Yes. Select each rule you need and the builder generates combined output. Rules are added in the recommended order. You can also manually edit the generated output before saving.
- How do I test .htaccess rules?
- Enable mod_rewrite logging (LogLevel alert rewrite:trace3) in a development environment, or use Apache's apachectl -t to check syntax. Online tools like htaccess.madewithlove.com can also simulate mod_rewrite behaviour.
- What mod_rewrite directives are essential to know?
- RewriteEngine On enables the engine. RewriteCond sets a condition that must match before the rule fires. RewriteRule defines the pattern and target URL. Flags like [R=301,L] set the redirect code (R) and stop processing further rules (L).