301 Redirect Generator: Apache .htaccess, Nginx, Next.js & Cloudflare
Generate clean 301 permanent and 302 temporary redirect rules for Apache .htaccess, Nginx, Next.js, and Cloudflare.
301 & 302 Redirect Rule Generator
Preserve SEO link equity during domain migrations, slug updates, and content restructuring.
// Place in next.config.ts / next.config.js inside redirects()
async redirects() {
return [
{
source: '/blog/old-article-title',
destination: 'https://example.com/guides/new-article-title',
permanent: true,
},
];
}What this tool does and who it is for
This tool writes the code for a single redirect. Enter an old path and a new destination URL, choose a status code of 301, 302, 307 or 308, and pick a format: Next.js redirects(), Apache .htaccess, an Nginx location block or a Cloudflare forwarding rule note.
The output is one rule for one URL. For the Apache option it is a Redirect line, and for Nginx it is an exact-match location block that returns your chosen code and URL.
Redirects tell browsers and search engines that a page moved. Add them whenever you change a slug, merge pages or move domains, and test every rule after you deploy.
Official Formula / Technical Standard
Real-World Worked Scenario
Redirecting /blog/seo-tips to /guides/seo-tips passes ranking signals within 48-72 hours.
When people use it
Changing a blog slug
Redirect the old post URL to the new one so existing links and bookmarks still work.
Merging thin pages
Send several weak pages to one stronger guide with a 301 each.
Moving from HTTP or an old domain
Use the rule format your host supports to move individual URLs to the new address.
Notes for US users
- A 301 is the usual choice for a permanent move and Google treats it as a strong signal to pass the old URL's signals to the new one. Use a temporary code only if you plan to restore the old URL.
- Send each old URL to its closest equivalent. Redirecting many pages to the homepage can be treated as a soft 404 by Google.
- Many US hosts, such as shared cPanel plans, run Apache, so .htaccess is common. Managed platforms like Vercel and Netlify use their own config, so use that one instead.
Limits and what to double-check
- •It handles one exact path at a time. There are no wildcard, regex or bulk options, so a large migration needs a script or a spreadsheet-driven process.
- •The Cloudflare output is instructions for a Page Rule with a placeholder domain, not code you can import, and it covers only 301 and 302 labels.
- •Nothing is checked. A path typed without a leading slash, or a loop between two rules, will not be caught, so test the real URLs.
Expert Best Practices & Common Pitfalls
Recommended Best Practices
- •Avoid redirect chains (A → B → C). Always redirect directly from A to C.
Common Mistakes to Avoid
- •Using temporary 302 redirects during permanent migrations, which prevents PageRank transfer.
Step-by-Step Instructions
Enter Old Path
Type the source URL path you are deprecating.
Enter New Destination
Type the target canonical destination URL.
Select Server & Status
Choose Apache, Nginx, or Next.js and copy the rule.
Features & Security Architecture
- Multi-Server Output: Apache .htaccess, Nginx server block, Next.js async redirects(), Cloudflare
- Status Code Options: 301 (Permanent), 302 (Temporary), 307 (Method Preserved), 308 (Permanent Method Preserved)
- Passes Full PageRank: Follows Google standards for 100% link equity transfer
- Instant Syntax Highlighting: Clean one-click copy
Frequently Asked Questions
Does a 301 redirect hurt SEO rankings?▼
No. Google confirms that 301 redirects pass 100% PageRank link equity without ranking loss.
How long should I keep a 301 redirect?▼
Google has suggested keeping redirects in place for at least a year, and longer if you can, since old links and bookmarks keep sending traffic. If you remove one too soon, visitors and signals hit a 404. In practice, leave them indefinitely.
What is the difference between 301 and 308?▼
Both are permanent. A 308 requires the browser to repeat the same request method, so a POST stays a POST, while older 301 handling may change it to GET. For ordinary page moves on the web, 301 is the familiar choice and works fine.
Should I redirect or use a canonical tag?▼
Use a redirect when the old URL should stop being used, so visitors land on the new page. Use a canonical when both URLs must remain available but one is preferred for search. A redirect is stronger and also changes what users see.
Why does my redirect loop?▼
Usually two rules point at each other, or a rule runs again after the new URL matches the same pattern, as with HTTP to HTTPS plus a www rule. Trace the chain with a browser's network tab or a header checker, then remove the conflicting rule.