PBNLinksHub
Get Started
Technical SEO ToolsRuns in your browserFree · no sign-up

Redirect Rule Generator

Paste pairs of old and new URLs and get ready-to-use redirect rules for Apache (.htaccess) or Nginx — permanent or temporary, with correct query-string handling, optional HTTPS and www rules, and warnings for chains, loops and duplicates.

Redirect Rule Generator

Separate with a space, tab, comma or →. Paths start with /. Targets can be paths or full URLs.

Site-wide rules (optional)
.htaccess rules

How to use the Redirect Rule Generator

  1. Paste your redirect map

    One redirect per line: the old path, then the new path or URL.

  2. Choose type and server

    301 for permanent moves; 302 only for genuinely temporary ones. Pick Apache or Nginx.

  3. Add site-wide rules (optional)

    Force HTTPS and choose www or non-www, with your domain.

  4. Test before going live

    Add the rules on staging if you can, then check a sample with the HTTP Status Code Checker.

What it checks

Input format
Each line needs a source path starting with / and a target path or absolute URL.
Duplicates
The same source redirected more than once — only the first rule would ever apply.
Chains
A target that is itself the source of another redirect, which creates extra hops.
Loops
Redirects that lead back to their own source, directly or via others.
Query strings
Sources with ?parameters need RewriteCond (Apache) or $arg matching (Nginx); handled automatically.
Special characters
Spaces and regex characters in paths are escaped or encoded.

Interpreting the results

The output panel shows a complete, commented block of rules for the chosen server. For Apache, each redirect is a RewriteRule with an anchored, escaped pattern, and a source that includes a query string gets a matching RewriteCond %{QUERY_STRING} line. For Nginx you get exact-match location = /path blocks; query-string sources are checked with $args inside the block.

Warnings below the output list duplicates, chains and loops with the line numbers involved. Chains are resolved in the notes (A → B → C becomes “redirect A straight to C”), but the generated rules follow your input exactly so nothing changes silently.

Detected marks facts read directly from what you provided. Guidance marks general recommendations based on those facts — rules of thumb, not guarantees or search engine requirements.

Practical guidance

Redirects are how you keep the value of old URLs after a migration, a slug change or a content merge. Every URL that has earned backlinks or traffic should redirect with a single permanent hop to the most relevant new page — not to the homepage, and not through a chain.

A realistic example: after moving a blog from /2019/05/post.html URLs to /guides/post/, you paste 120 pairs. The generator flags three chains, because some posts were already redirected once in 2022. Updating those lines to point at the final URLs saves every visitor and crawler an extra request.

After deploying, verify a sample with the HTTP Status Code Checker, which shows each hop. Links you build should point directly at final URLs — part of how we prepare PBN backlinks and backlink packages. Our common link building mistakes guide covers redirected targets.

Limitations

  • It writes rules; it can't install or test them on your server. Syntax is standard, but hosting setups vary.
  • Apache rules assume mod_rewrite is enabled; Nginx blocks belong inside the relevant server block.
  • Pattern-based redirects (whole folders or regular expressions) aren't generated — only one-to-one mappings plus HTTPS/www rules.

Frequently asked questions

301 or 302?

Use 301 (or 308) when the move is permanent. 302 and 307 are for temporary moves, such as a short promotion.

Where do the Apache rules go?

In the .htaccess file in your site root, after RewriteEngine On and before any CMS rules such as WordPress's block.

Why not just redirect everything to the homepage?

Search engines may treat irrelevant redirects like missing pages. Redirect each old URL to its closest equivalent.

Is my list uploaded?

No. Rules are generated in your browser.

More in Technical SEO Tools · All 25 free SEO tools