Every site eventually moves a page. The product gets renamed, the blog changes its URL scheme, a whole section migrates to a new domain. The old address is still out there in bookmarks, search results and other people's links, and if it simply stops working, every one of those visits lands on an error page.
A redirect rule is how you close that gap properly. This guide explains what a 301 actually promises, how it differs from the other status codes, and how to generate correct rules for Apache, Nginx or a _redirects file with the free Redirect Rule Generator on Ovatly.
Contents
- Quick answer
- What a 301 redirect actually promises
- 301, 302, 307 and 308: picking the right code
- One set of rows, three output formats
- How to write a 301 redirect rule, step by step
- Worked example: two permanent moves
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
List each old path and its destination in the Redirect Rule Generator, set the status code to 301 for a permanent move, choose the output format your server or host uses, and copy the generated block into your configuration. The generator validates the rows before producing anything, and it produces Apache .htaccess lines, Nginx rules, or the _redirects format used by Cloudflare Pages and Netlify. Test every redirect after deploying, because the generator checks the shape of the rules, not whether the destinations exist.
What a 301 redirect actually promises
A 301 is a permanent move, stated in a form machines act on. When a browser receives a 301, it may cache the new address and go straight there next time. When a search engine receives one, it treats the move as final and transfers the ranking signals from the old URL to the new one. The old address stops being the canonical home of that content.
That permanence is exactly why a 301 is the right default for renamed pages and restructured sites, and the wrong choice for anything you might reverse. A temporary campaign page, a short-lived test, or a move you plan to undo should not be announced as permanent, because browsers and search engines will believe you.
301, 302, 307 and 308: picking the right code
The generator supports four codes, and each row can carry its own.
- 301, permanent. The move is final. Ranking signals transfer and the new URL becomes canonical. Use it for renames, restructures and domain migrations.
- 302, temporary. The move is for now. The original URL stays the canonical one, so use it when the old address will come back.
- 307, temporary with the method preserved. The request is repeated at the new address exactly as it was sent, which matters for form posts and API calls.
- 308, permanent with the method preserved. The permanent version of 307: final move, exact method.
For ordinary page moves, the choice is between 301 and 302, and it comes down to one question: is the old address ever coming back? If not, 301.
One set of rows, three output formats
Servers disagree about how a redirect is written, so the generator produces the format your setup expects from the same rows.
Apache takes .htaccess Redirect lines. Nginx takes rewrite rules for 301 and 302, using the permanent and redirect flags; for 307 and 308 it generates an exact-match location block with a return directive, because rewrite cannot emit those codes. In Nginx output, regex characters in the from path, such as the dot in /old.html, are escaped automatically so the pattern matches the literal path. Hosts such as Cloudflare Pages and Netlify take a plain _redirects file at the root of the published site, one line per rule: from, destination, status code.
You enter the moves once. Switching formats is a menu choice, not a rewrite.
How to write a 301 redirect rule, step by step
- Open the Redirect Rule Generator and enter a from path and a destination for the first redirect. The destination can be a path on the same site or a full URL on another domain.
- Pick the status code for that row: 301 for a permanent move, or 302, 307 or 308 where the situation calls for them.
- Add a row for each additional redirect. If two rows share the same from path, the generator refuses them, because a server would apply the first match and silently ignore the second.
- Choose the output format for your server or host, fix any validation messages, then copy or download the generated block.
- Paste the rules into your
.htaccessfile, your Nginx configuration, or your_redirectsfile, deploy, and then visit each old address yourself to confirm it lands where you intended.
Worked example: two permanent moves
Suppose a shop renames a product page and moves a blog post into a journal section. The rows are:
/old-soapto/soap, code 301/blog/post-1to/journal/post-1, code 301
In Nginx format, the generator produces:
rewrite ^/old-soap$ /soap permanent;
rewrite ^/blog/post-1$ /journal/post-1 permanent;
The same rows in Apache .htaccess format:
Redirect 301 /old-soap /soap
Redirect 301 /blog/post-1 /journal/post-1
And in the _redirects format for Cloudflare Pages or Netlify:
/old-soap /soap 301
/blog/post-1 /journal/post-1 301
Same two moves, three dialects. Pick the one your server speaks and paste it in unchanged.
Limitations and honest tradeoffs
The generator validates shape only. It confirms that each row is a well-formed rule with a valid code, and it catches structural problems such as a duplicated from path. It cannot know whether the destination exists, whether the destination itself redirects somewhere else, or whether your server already carries a conflicting rule written by hand. A generated block can be perfectly valid and still point at a page that returns a 404.
Server behaviour also differs in the details. A rule that works on your staging host may meet existing configuration on production that takes precedence. The only reliable check is the boring one: deploy, then request each old URL and watch where it lands and which status code comes back.
Common mistakes
- Using 301 for a temporary move. Browsers cache it and search engines treat it as final. Undoing a cached 301 is slow and unreliable, so reach for 302 when the move might reverse.
- Writing two rules for the same path. The second never runs. Merge them into one row with one destination.
- Redirecting to a page that does not exist. The rule is valid and the visitor still hits an error. Create or confirm the destination first.
- Chaining redirects by accident. If the destination of one rule is the from path of another, visitors bounce through both. Point every old address directly at the final one.
- Skipping the test. Configuration typos fail silently. Visit each old address after deploying and confirm the landing page and the status code.
FAQs
What is the difference between a 301 and a 302 redirect? A 301 is permanent: browsers and search engines treat the move as final and transfer ranking signals to the new URL. A 302 is temporary: the original URL stays the canonical one. Use 307 or 308 when the request method must be preserved exactly; 308 is the permanent version of 307.
Can the destination be a full URL on another domain? Yes. Enter the complete https:// address as the destination. That is the standard way to move pages between domains.
Why did the generator refuse two rows with the same from path? Servers apply the first matching rule and ignore the rest, so a second rule for the same path would silently never run. Merging them into one row avoids a configuration that looks right but does nothing.
Where does the _redirects file go? At the root of the published site, in the output folder alongside index.html, on Cloudflare Pages and Netlify. Each line is: from, destination, status code.
Does the generator check that my destination page exists? No. It validates the shape of the rules only. It cannot know whether the destination exists or whether your server already has conflicting rules, so test the redirects after deploying them.
Conclusion
A good redirect is a promise kept: the old address still works, and it lands on the right page with the right status code. Enter the moves once in the Redirect Rule Generator, take the format your server speaks, and test every line after deploying. If the content itself is changing format during the same migration, our guide on how to convert Markdown to HTML covers producing the new pages. For more in this series, see the Website and Webmaster Tools guides.
References
- MDN Web Docs, on HTTP redirections and status codes: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Redirections
- Cloudflare Pages documentation, on the _redirects file: https://developers.cloudflare.com/pages/configuration/redirects/