Global Canonical Rules
Force HTTPS Security
Redirect all HTTP traffic to HTTPS via 301


Custom Route Mapping
Live .htaccess Rules

      
Total Custom Routes
0
redirect rules defined
🔒 HTTPS Not Enforced
Redirect Chain Risk
No chains detected
    Total Directives
    0
    lines of Apache config
    📚 Key Terms Explained
    .htaccess
    A hidden Apache server configuration file placed in a directory. It overrides server-level settings for that directory and its subdirectories without restarting the server.
    Apache Web Server
    The world's most widely deployed web server software. Apache processes HTTP requests, serves files, and executes directives defined in .htaccess and httpd.conf files.
    301 Permanent Redirect
    An HTTP status code signaling that a resource has permanently moved to a new URL. Search engines transfer link equity to the new URL and update their index accordingly.
    302 Temporary Redirect
    An HTTP status code indicating a resource has temporarily moved. Search engines keep the original URL indexed and do not pass link equity, making 302 wrong for permanent moves.
    Canonicalization
    The process of choosing one preferred URL version when multiple variants exist (HTTP vs HTTPS, www vs non-www). Canonicalization prevents duplicate content penalties in search engines.
    mod_rewrite
    An Apache module that provides a rule-based URL rewriting engine using regular expressions. It powers the RewriteRule and RewriteCond directives and must be enabled on the server.
    Regular Expressions (Regex)
    A pattern-matching syntax used in RewriteRule and RedirectMatch to identify URL patterns. Characters like ^ (start), $ (end), and .* (any characters) form the building blocks.
    Redirect Chain
    A sequence of redirects where URL A points to URL B, which then points to URL C. Chains waste crawl budget, slow page loads, and dilute SEO signals passed through each hop.

    The Complete Guide to Apache .htaccess Redirects

    Managing URL redirects is one of the most consequential tasks in technical SEO and server administration. A single misconfigured rule can create redirect loops, break crawling, or silently bleed link equity. This guide covers every pattern generated by this tool so you can deploy with confidence.

    How to Use This Tool

    Set your global rules in the left panel first: toggle HTTPS enforcement on or off, choose your WWW preference, and set your trailing slash behavior. Enter your base domain if you are enforcing a WWW or non-WWW canonical. Then use the Custom Route Mapping panel to add individual path redirects. The .htaccess output updates in real time as you type - no submit button needed. When finished, click "Copy Rules" and paste the content into your .htaccess file at your site root.

    Understanding the Output: Global vs. Route-Level Rules

    The generated file uses RewriteRule directives with RewriteCond conditions for global canonicalization, because these require server variable checks (like %{HTTPS} or %{HTTP_HOST}) that only mod_rewrite can access. For individual path routes, the tool uses RewriteRule with the R= flag, which is clean and explicit. The [L] flag on every rule means "last" - Apache stops processing further rules if this one matches, preventing unintended rule stacking.

    Slash Warning System

    If you omit the leading slash on an Old Path or New Path input, the tool outlines the field in amber and auto-prepends the slash in the generated output. Apache path matching requires an absolute path beginning with /. Omitting it is the most common cause of 500 Internal Server Errors in hand-written .htaccess files.

    Deploying Safely

    Always test your .htaccess rules on a staging server before pushing to production. After deploying, use a redirect checker tool to walk each URL and confirm it resolves in a single hop to the expected destination. Keep a backup of your previous .htaccess file. If Apache returns a 500 error after updating, the most common cause is a syntax error in the file - check your server's error log at /var/log/apache2/error.log or its equivalent.

    Frequently Asked Questions

    Why is a 301 redirect better for SEO than a 302?
    A 301 redirect signals to search engines that a page has permanently moved, so they transfer the original page's link equity (PageRank) to the new URL and update their index. A 302 tells crawlers the move is temporary, so they keep both URLs in the index and do not pass link equity. Using a 302 when you mean a permanent move can split your ranking signals across two URLs and dilute your SEO value.
    What is a redirect chain and why is it bad?
    A redirect chain occurs when URL A redirects to URL B, which then redirects to URL C. Each hop adds latency for real users and causes search engine crawlers to spend extra crawl budget following the chain. Some crawlers will also stop following after a certain number of hops, meaning the final destination may never be indexed. Fix chains by pointing the original URL directly to the final destination. This tool flags chains in the analysis pane whenever a New Path you define matches another row's Old Path.
    Do I need to force HTTPS in my .htaccess file?
    If your server or CDN (like Cloudflare) does not already handle HTTPS enforcement at the edge, yes - adding a mod_rewrite rule to redirect all HTTP traffic to HTTPS is the right approach. However, if your hosting platform handles it automatically (as Cloudflare Pages and many managed hosts do), adding a duplicate .htaccess rule is harmless but unnecessary. When in doubt, include it: the rule is cheap and the security benefit is real.
    What is the difference between RedirectMatch and RewriteRule?
    RedirectMatch is a simpler directive from mod_alias that matches a regex against the request path and issues a redirect. It runs before mod_rewrite and has no conditions. RewriteRule (from mod_rewrite) is more powerful: it can match the full URL, use RewriteCond conditions to check headers, server variables, or query strings, and can rewrite internally (not just redirect). For basic path redirects, either works. For conditional logic like HTTPS or WWW enforcement, RewriteRule with RewriteCond is required.