301 Redirect Generator

A redirect sends anyone who visits an old address straight to a new one. They never see an error, they just land in the right place.

Pick what you are moving from the tabs, fill in the two addresses, and copy the rule. Everything happens in your browser, nothing is sent anywhere.

Apache or LiteSpeed (.htaccess) Most hosts

Paste this ABOVE the line that says # BEGIN WordPress. Rules placed after it never run.

Nginx

Goes inside the server block. Nginx has no .htaccess, so this needs server access or a host that offers a rules field.

Redirection plugin No file editing

Safest option if you would rather not touch server files. Tools > Redirection in wp-admin.

Which tab do I need?

Match your situation to one of these. Picking the wrong one is the usual reason a rule does nothing.

One page

You changed a single page’s address. You renamed /pricing.html to /plans/, or rewrote a post and gave it a better URL.

Only that one address is affected. Anything else on the site carries on as normal.

A whole folder

You moved a section. Everything that was under /blog/ now lives under /articles/.

This keeps the rest of each address intact, so /blog/my-post/ becomes /articles/my-post/ automatically. You do not write a rule for every page, just this one.

HTTP to HTTPS

You installed an SSL certificate and want everyone forced onto the secure version, so nobody ever lands on the padlock-free one.

www and non-www

Your site answers to both example.com and www.example.com, and you want to settle on one.

Worth doing. Google can treat the two as separate websites, which splits your ranking between them instead of adding it up. Which one you pick genuinely does not matter, only that you pick.

A whole domain

You changed your domain name entirely and want the old one pointing at the new one, keeping every page’s path.

This only works while the old domain is still yours and still running. Once it expires, the redirect goes with it.

301 or 302

The tool asks you to pick. It matters more than it looks.

301 means permanent. Search engines move the old page’s ranking to the new one and eventually forget the old address. Browsers remember it too.

302 means temporary. Nothing is transferred and the old address stays in the index.

Use 301 for almost everything. Use 302 only when the old address is genuinely coming back, like a page redirected during maintenance or a seasonal offer.

One warning that catches people. Browsers cache 301s aggressively. Chrome will keep sending you to the new address long after you have deleted the rule, and you will swear the file did not save.

So while you are testing, use a private window, or set it to 302 first and switch to 301 once you are certain it is right.

Where the rule goes

The tool gives you three versions of the same rule. You only need one, and which one depends on your host.

.htaccess, which is most people

If you are on shared hosting, this is almost certainly you. Hostinger, Bluehost, HostGator, Namecheap and SiteGround all use it.

Open your hosting File Manager and go to public_html. The file sits alongside wp-config.php. It starts with a dot, so it may be hidden until you turn on “show hidden files” in the file manager settings.

Download a copy before you change it. A broken .htaccess takes the entire site down with a 500 error, and the fix is simply putting the old file back. Ten seconds now saves a very bad twenty minutes later.

Now the part that matters most on this whole page:

Paste your rule above the line that says # BEGIN WordPress.

RewriteEngine On
RewriteRule ^old-page/?$ /new-page/ [R=301,L]

# BEGIN WordPress
# ... leave everything below this alone

WordPress’s own block ends with an [L] flag, which means “stop here”. Anything after it is never read. Put your rule below and it will look perfect and do absolutely nothing, which is the single most common reason people think a correct rule is broken.

Nginx

Nginx ignores .htaccess completely. The rule goes into the server configuration and needs a reload to take effect.

On managed hosting you usually cannot edit that yourself. Either send the Nginx block to your host’s support, or use the plugin method below, which works on any server.

The Redirection plugin

The safe option if you would rather not touch server files at all, and the one to choose if you are nervous.

Install the free Redirection plugin, go to Tools then Redirection, and copy the Source and Target from the tool above. Where it says Regex ON, tick the Regex box, because the rule uses a pattern rather than a plain address.

The difference worth knowing: a plugin redirect loads all of WordPress first and then redirects. A server rule redirects before WordPress even starts. For a handful of redirects nobody will ever notice. For thousands, do it at server level.

The other difference is what happens when you make a mistake. A bad plugin entry breaks one redirect. A bad .htaccess breaks the whole site.

Checking it worked

Open a private browser window and visit the old address. You should land on the new one.

Use a private window every time. A normal one may still have the old page cached, or an old redirect remembered, and you will end up debugging something that is already working.

The mistakes that cost people a weekend

Redirect loops

The browser says “too many redirects” and nothing loads at all.

Usually the rule sends a page to itself, because the pattern matches the destination as well as the source. If you redirect /blog/ to /blog/new/, the new address still starts with /blog/, so it matches again, and again.

The other common cause is forcing HTTPS behind Cloudflare. Your server still sees plain HTTP even though the visitor is on HTTPS, so it redirects forever. The rule this tool builds checks X-Forwarded-Proto as well as %{HTTPS}, which is exactly what prevents that.

Redirect chains

Page A points to B, and B points to C. Every hop adds delay and loses a little of the ranking strength being passed along.

When you move a page that was already redirected once, go back and update the original rule to point at the final destination. Do not add another rule on top.

Sending everything to the homepage

Very tempting when you delete a lot of pages at once, and it throws away everything you were trying to save.

Google treats a redirect to an unrelated page as a soft 404 and passes nothing across. Send each page somewhere genuinely related, or let it return an honest 404. A clean 404 is better than a misleading redirect.

Forgetting the pattern is a regular expression

In a rewrite rule, a dot means “any character”. So an unescaped /pricing.html also matches /pricingXhtml and anything else in that shape.

The tool escapes these for you, which is why the output shows pricing.html. If you ever write one by hand, remember the backslash.

Putting a leading slash in the pattern

Inside .htaccess, a RewriteRule pattern must not begin with a slash. Write ^old-page, never ^/old-page.

With the slash the rule simply never matches, silently, and everything looks correct. This trips up people copying examples from server configuration guides, where the slash does belong.

It is not working

Run down this list in order.

  1. Is the rule above # BEGIN WordPress? Fixes most cases on its own.
  2. Are you testing in a private window? An old cached 301 will keep firing.
  3. Does the pattern have a leading slash it should not have?
  4. Is a caching plugin or Cloudflare still serving the old page? Clear both.
  5. Is your host actually Nginx? Then .htaccess is being ignored entirely.

If the whole site goes down with a 500 error, put back the copy of .htaccess you downloaded first. The site returns immediately and you can try again.

Questions people ask

How long should I keep a redirect?

At least a year, and there is no reason to ever remove it. Google usually moves the ranking within a few weeks, but old links, bookmarks and emails keep sending people for years afterwards. Redirects cost nothing to leave in place.

Do redirects hurt SEO?

A single well aimed 301 is exactly what search engines want when a page moves. What causes damage is chains, loops, and redirecting to pages that have nothing to do with the original.

Can I redirect a URL with a question mark in it?

Not with these rules. Anything after a ? is a query string, and a rewrite rule does not look at that part of the address. It needs a separate RewriteCond on %{QUERY_STRING}.

That case is fiddly enough that it is worth writing by hand rather than trusting a generator to guess.

Will visitors notice?

No. It happens in a few milliseconds before the page renders. The only sign is that the address bar shows the new address.

How many redirects is too many?

In .htaccess, a few hundred is fine. Thousands will start to slow things down, because the server reads the file on every single request. At that scale, folder rules instead of individual page rules, or moving them into the server configuration, is the answer.