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.

Safety first: back up your existing .htaccess file before changing it. One bad rewrite can turn a site into a very dramatic paperweight.
Quick tests after adding a rule apachectl configtest curl -I https://example.com/old-url tail -f /usr/local/apache/logs/error_log

Builder

Choose a rule

Use a path, not the full domain, unless the field says otherwise.
For redirects, this is where the visitor should end up.
Used for www/non-www and canonical host redirects.
Used when a clean URL should load an existing file.
Use your own IP for allow/block rules.
Use 301 only when you are confident the redirect is permanent.
Options

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.