Apache tool
.htaccess Rule Builder
Generate common Apache rules for redirects, clean URLs, HTTPS, www/non-www, access control and simple headers. Choose a rule type, fill in the fields, then copy the generated snippet.
.htaccess file before changing it. One bad rewrite can turn a site into a very dramatic paperweight.
apachectl configtest
curl -I https://example.com/old-url
tail -f /usr/local/apache/logs/error_log
Output
Generated .htaccess snippet
Choose a rule type and click Build rule.
What this rule does
The explanation will update when you build a rule.
How to test it
curl -I https://example.com/old-page
Examples
Common .htaccess tasks
Redirect old pages
Use this after changing article slugs, removing .html URLs or consolidating duplicate pages.
Fix canonical hosts
Force one preferred version of the site, such as HTTPS and non-www, to avoid duplicate URL confusion.
Serve clean URLs
Route a clean URL like /blog to a real file like blog.php without showing the extension.
FAQ
.htaccess builder notes
Where should I put generated rules?
Put specific redirects near the top, before generic fallback rules. If a general rule appears first, it may catch the request before your specific rule runs.
Should I use 301 or 302 redirects?
Use 301 for permanent URL changes. Use 302 for temporary tests or short-term moves.
Can a bad rule break the site?
Yes. Always back up .htaccess first, then test with curl -I before assuming it works.