331+ free tools. No sign-up. No hidden fees. Explore the toolkit

Redirect Rules Generator

A redirect sends visitors — and search engines — from an old URL to a new one, so a moved page does not become a dead end. Get it right and your rankings and bookmarks survive the move; get it wrong and you get 404 errors, lost traffic and broken links.

Enter your old and new URLs and get ready-to-use redirect rules for Apache .htaccess, nginx and Cloudflare — in 301 or 302 form, with duplicate checks built in.

301 passes most ranking signals to the new URL. Use 302 only while a move is genuinely temporary.

Your Redirect Rules

Apache (.htaccess)

nginx

Cloudflare (_redirects)

Save to Pinterest

How It Works

A redirect is an instruction from your server: when someone requests an old URL, the server answers with a status code (301 for permanent, 302 for temporary) and the new address, and the browser goes there automatically. Search engines follow the same instruction — with a 301 they pass most of the old page's ranking signals to the new page and update their index; with a 302 they keep the old URL in the index because the move is temporary. Clean URLs start with clean slugs — a text-to-slug generator turns any title into a short, hyphenated slug.

Each server writes redirects differently. Apache uses Redirect 301 /old /new lines in .htaccess; nginx uses rewrite rules inside a server block, with permanent for a 301 and redirect for a 302; Cloudflare uses a plain _redirects file with one old new status line per rule. This generator produces all three from the same list, so you can copy whichever one your host uses. Some redirects also depend on who is asking — a rule can send mobile browsers somewhere different, which is where a user-agent parser comes in: it reads the UA string the browser sends.

Worked Example

One pair — /old-page to /new-page — as a 301 produces exactly these rules:

Apache .htaccess:
Redirect 301 /old-page /new-page

nginx:
rewrite ^/old-page$ /new-page permanent;

Cloudflare _redirects:
/old-page /new-page 301

How to Use This Tool

Enter your pairs and click Generate Redirect Rules. Copy the block for your server and add it to the right file.

  1. Enter old and new URLs. Add rows one pair at a time, or switch to paste mode and paste a list — one pair per line, old and new separated by a comma or a tab. Both fields are required for every pair.
  2. Choose 301 or 302. 301 (permanent) is the default and the right choice for moved pages. Use 302 only while a move is genuinely temporary.
  3. Copy the block for your server. Apache users paste into .htaccess at the site root; nginx users paste into the server block and reload nginx; Cloudflare Pages users paste into a _redirects file.
  4. Test every redirect. Open each old URL in a browser and confirm it lands on the right new page. A typo in one rule can break a whole section of your site.

If the same old URL appears twice in your list, the tool warns you — duplicate rules are the most common cause of redirect chains and loops, where a visitor bounces between URLs or never arrives at all.

Tips and Practical Advice

Frequently Asked Questions

What is the difference between a 301 and a 302 redirect?

A 301 is permanent: search engines pass most ranking signals to the new URL and update their index. A 302 is temporary: they keep the old URL indexed because the move is not final. Use 301 for moved pages and 302 only while a move is genuinely temporary.

Where do I put the .htaccess rules?

In the .htaccess file at the root of your site, on an Apache server. Back the file up first, paste the rules, and test one old URL in a browser — a typo in .htaccess can break the whole site.

What is a redirect chain, and why should I avoid it?

A chain is when /a redirects to /b, which redirects to /c. Every hop slows visitors down, wastes crawl budget and loses some ranking signal. Always point old URLs directly at the final destination.

Do I need the full domain in the new URL?

Not for a destination on the same site — a path such as /new-page works for Apache, nginx and Cloudflare. For a different domain, use the full URL, for example https://example.com/new-page.

How do I check my redirects work?

Open each old URL in a browser and confirm it lands on the right new page. For the status code itself, use a redirect checker tool or run curl -I on the old URL and look for 301 or 302 in the response.

Last updated: