301 Redirect Generator: Create .htaccess Redirects Without Errors

This 301 redirect generator turns old and new URLs, one pair or a whole migration list, into clean rules for Apache and LiteSpeed servers, with an Nginx version too. It flags loops, duplicates and chains before the code reaches your .htaccess file.

Free, no sign-upRuns in your browserNothing is uploaded
Redirect rules
A path like /old-page/ or a full URL. Addresses with ?parameters are supported.
Generated code

Back up .htaccess first, paste the rules above # BEGIN WordPress, then open an old URL in a private window. If the site shows error 500, restore the backup.

Fill in the fields to generate the rules.Everything runs in your browser. Your URLs are not sent anywhere.
  1. 1. PasteEnter an old and a new URL, or a list of pairs for a whole migration.
  2. 2. CheckFix the loops, duplicates or chains the generator flags.
  3. 3. CopyPaste the rules into .htaccess above the WordPress block and test.

What is a 301 redirect?

A 301 redirect is a server response that tells browsers and search engines a page has moved permanently to a new address. Google treats it as a strong signal to index the new URL and passes ranking signals to it. The status code is defined in RFC 9110 as “Moved Permanently”.

On most hosting you set redirects in the .htaccess file, which Apache and LiteSpeed servers read, including most cPanel plans. Nginx ignores .htaccess, so this 301 redirect generator also prints the same rules in Nginx syntax with return 301.

How to create 301 redirects in .htaccess in 4 steps

To create a 301 redirect in .htaccess, back up the file, generate the rules, paste them above the WordPress block and test an old URL. The whole job takes a few minutes.

  1. Back up .htaccess. Download a copy through FTP or the hosting file manager before you change anything. The file sits in the site root, next to wp-config.php on WordPress.
  2. Generate the rules. Pick a redirect type, enter the old and new addresses or paste a list in Bulk mode, and fix the warnings the generator shows.
  3. Paste above # BEGIN WordPress. Put the whole block, from # BEGIN Ideluma redirects to # END Ideluma redirects, at the top of .htaccess. WordPress rewrites everything between its own markers, so rules placed inside them get lost.
  4. Test in a private window. Open an old URL and check that it lands on the new one. Browsers cache 301 responses, so a normal window may keep showing the old result.

If the site shows error 500 after saving, restore the backup at once: one typo in .htaccess stops the whole site, and the copy brings it back in seconds. The generator writes the rules but can’t see how your server answers, so always open a few old URLs after the change.

301 vs 302 vs 307 vs 308: which redirect to use

Use 301 for any page or site that moved for good, and 302 only for a temporary move. 307 and 308 do the same jobs while keeping the request method, which matters for forms and APIs.

301

NameMoved Permanently

Permanent?Yes

Keeps request methodNot guaranteed

Use it whenA page or site moved for good. The standard SEO redirect

302

NameFound

Permanent?No

Keeps request methodNot guaranteed

Use it whenTemporary move: A/B test, maintenance, seasonal page

307

NameTemporary Redirect

Permanent?No

Keeps request methodYes

Use it whenTemporary move of forms or APIs that use POST

308

NamePermanent Redirect

Permanent?Yes

Keeps request methodYes

Use it whenPermanent move of forms or APIs

Google describes how it treats each type in Redirects and Google Search. A temporary code keeps the old URL in the index, so choose 302 only when the page is really coming back.

Ready-made .htaccess redirect rules

These six rules cover most redirect tasks. The 301 redirect generator writes the same code with your addresses, inside its # BEGIN and # END markers.

A single page moves to a new address:

# One page to another
Redirect 301 /old-page/ https://example.com/new-page/

Every http:// request goes to https:// on the same host:

# HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

Visitors on www.example.com land on example.com with the same path:

# www to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

The site moves to a new domain and every path stays the same:

# Old domain to new domain, keeping paths
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]

A folder moves and every page inside it follows:

# Whole folder to a new folder
RedirectMatch 301 ^/blog/(.*)$ https://example.com/articles/$1

An address with a query string goes to a clean URL:

# Page with a query string (?id=12) to a clean URL
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=12$
RewriteRule ^product\.php$ https://example.com/product-name/? [R=301,L]

Redirect and RedirectMatch never see the part after ?, so an address with a query string needs RewriteCond %{QUERY_STRING} and RewriteRule, as in the last rule. The ? at the end of the new URL drops the old parameters.

Bulk redirects for site migrations

A bulk 301 redirect generator handles a whole redirect map at once: switch to Bulk, paste one old and one new URL per line, or open a CSV file exported from a spreadsheet.

  • Build the map from real URLs. Export the old sitemap or the indexed pages from Google Search Console, so no page with traffic is left out.
  • Send each page to its closest match. A product goes to the same product, a category to the new category.
  • Let the generator order the rules. Redirect also catches every address under a path, so the tool places longer paths first and tells you.
  • Press Fix chains. When one line points to a URL that another line redirects again, the button sends it straight to the final address.
  • Keep the list. Download the rules as .txt and store them with the migration notes.

When the whole domain changes, add the domain rule too and report the move in the Change of Address tool in Google Search Console.

Common redirect mistakes that hurt SEO

Most redirect problems come from a few repeated mistakes, and each one either wastes crawling or loses the page’s ranking signals.

  • Redirect chains. A → B → C adds a hop for every visitor and bot. Point A straight to C.
  • Loops. A URL that redirects to itself, or two rules that point at each other, end in a browser error.
  • 302 instead of 301. A temporary code keeps the old URL in the index.
  • Everything to the homepage. Google may treat mass redirects to an unrelated page as soft 404s.
  • Forgotten parameters. Redirect ignores query strings, so /product.php?id=12 needs a rewrite rule.
  • HTTPS and www in two hops. Separate rules send http://www.example.com through two redirects; the type “HTTPS and non-www in one hop” does it in one.
  • Removing redirects too early. Keep them for at least a year after a move.

Where .htaccess works and where it doesn’t

The .htaccess file works on Apache and LiteSpeed servers, which covers most cPanel hosting, and has no effect on Nginx.

  • Apache and LiteSpeed. Paste the rules into .htaccess in the site root. Changes apply on the next request, with no restart.
  • Nginx. Switch the code to Nginx and add the blocks to the server configuration, then reload Nginx. location blocks go inside the existing server block; domain rules are separate server blocks.
  • Hosting without file access. Some site builders and managed platforms hide .htaccess; use their redirect settings instead.
  • WordPress plugins. A redirect plugin stores rules in the database and suits a handful of pages. Rules in .htaccess run before WordPress loads, so they keep working even if a plugin is switched off.

301 redirect FAQ

How do I do a 301 redirect in .htaccess?

Add a line such as Redirect 301 /old-page/ https://example.com/new-page/ to the .htaccess file in your site root, above the WordPress block. The 301 redirect generator writes this line for you, adds rewrite rules where needed and checks the list for loops and duplicates.

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

A 301 redirect says a page moved permanently, so search engines index the new URL and pass ranking signals to it. A 302 says the move is temporary, so the old URL stays in the index. Use 302 only for tests, maintenance or seasonal pages.

Are 301 redirects bad for SEO?

No. A 301 redirect is the method Google recommends when a URL changes, and it passes ranking signals to the new address. Losses come from chains, loops, redirects to unrelated pages and removing redirects too soon, which the warnings in this tool help you avoid.

How long should I keep a 301 redirect?

Keep 301 redirects for at least a year after a move, as Google advises for site migrations, and longer if old links still bring visitors. Removing them early turns every old link, bookmark and search result into a 404 page.

Where do I put redirects in a WordPress .htaccess file?

Put them at the top of the file, above the line # BEGIN WordPress. WordPress rewrites the section between # BEGIN WordPress and # END WordPress when permalinks are saved, so any rule placed inside that section disappears.

Why does my redirect cause a loop or error 500?

A loop happens when a URL redirects to itself or two rules point at each other, and the generator warns about both. Error 500 usually means a typo or a directive the server doesn’t support: restore the backup, then paste the generated block again without editing it by hand.

Does .htaccess work on Nginx?

No. Nginx does not read .htaccess files, so rules placed there have no effect. Switch the generator to Nginx, add the location or server blocks to your Nginx configuration and reload the server. Apache and LiteSpeed do read .htaccess.

How do I redirect HTTP to HTTPS?

Choose HTTP to HTTPS in the generator and paste the rule into .htaccess: it sends every http:// request to the same address on https://. Install the SSL certificate first, otherwise visitors land on a security warning instead of your page.

How do I redirect an old domain to a new one?

Choose Old domain to new domain, enter both domains and paste the rule into the .htaccess file of the old site. Every path keeps its place, so old-domain.com/page/ opens new-domain.com/page/. Then report the move in Google Search Console.

Can I redirect many URLs at once?

Yes. Switch to Bulk and paste one old and one new URL per line, separated by a space, tab or comma, or open a CSV file. There is no limit on the number of lines, and the generator checks the whole list for duplicates, loops and chains.

Why does my browser still show the old redirect?

Browsers cache 301 redirects, often for a long time, so your own browser may keep following an old rule after you change it. Test in a private window or clear the cache. Visitors who never opened the old URL get the new rule at once.

Other Ideluma tools

The 301 Redirect Generator is part of the free SEO toolkit on Ideluma. Check the snippet of a moved page with the SERP Simulator, or compare the old and new .htaccess with Text Compare.

Elevate your design process with AI-driven creativity.