Home Content Marketing Technical Images Blog

Redirect Generator

Generate precise 301 and 302 redirect rules for Apache, Nginx, Next.js, and Vercel to preserve your SEO rankings during migrations.

1. Server / Platform

2. Redirect Type

301 Permanent (SEO)
302 Temporary
Passes maximum link equity. Best for permanent URL changes.

3. URL Mapping

Switch to Bulk Mode
Usually a relative path starting with a forward slash.
APACHE .HTACCESS CODE

URL Redirects and SEO Preservation

Websites are living, breathing entities. Over time, you will inevitably restructure categories, update blog post titles, migrate to a new domain, or switch from an outdated CMS to a modern framework like Next.js. When this happens, the URLs of your web pages change.

To a search engine like Google, a changed URL is effectively a deleted page. If another website links to yoursite.com/old-page, and you change it to yoursite.com/new-page without telling the server, any user who clicks that link will hit a dead 404 Not Found error. Worse, all the SEO authority (PageRank) associated with that backlink evaporates instantly.

Redirects are the server-level instructions that fix this. They act as digital forwarding addresses. Our multi-platform Redirect Generator ensures your syntax is flawless, whether you are running a legacy Apache server or deploying to the modern Vercel edge network.

What is a Redirect? (301 vs. 302)

When a browser or search engine bot requests a URL, the server responds with a 3-digit HTTP Status Code. A "200 OK" means the page loaded successfully. A "404" means the page is gone. Status codes in the 300-range instruct the client to go to a different URL.

The 301 Redirect (Permanent)

A 301 redirect tells search engines: "This page has permanently moved to a new location. Please delete the old URL from your index, replace it with the new URL, and transfer all the SEO ranking power to the new page."

This is the absolute gold standard for SEO. According to Google, 301 redirects pass approximately 90% to 99% of the original page's link equity.

The 302 Redirect (Temporary)

A 302 redirect tells search engines: "This page is temporarily at a new location, but it will come back. Do not update your index, and do not transfer the SEO ranking power to the new page."

You should only use a 302 redirect for A/B testing, seasonal promotions (e.g., redirecting the homepage to a Black Friday landing page for a week), or during temporary site maintenance.

The Mathematics of Link Equity (PageRank)

Why are 301 redirects so critical? Because of Google's foundational algorithm: PageRank. Every link pointing to your website passes mathematical "votes" of confidence.

$$ PR(A) = (1-d) + d \sum \left( \frac{PR(T_i)}{C(T_i)} \right) $$

If page $A$ earns high PageRank, and you change its URL without a 301 redirect, that mathematical equation breaks. The value goes to zero. A 301 redirect acts as a bridge, ensuring the summation of $PR(T_i)$ successfully crosses the chasm from the old URL to the new URL.

Platform-Specific Implementations

Writing a redirect is not a universal process. The syntax changes entirely depending on the software powering your web server. Our tool supports the four most dominant architectures.

1. Apache (.htaccess)

Apache is the legacy king of the internet, powering millions of standard PHP and WordPress websites. Redirects are placed in a hidden configuration file in your root directory called .htaccess.

Our tool generates the RewriteRule syntax using Apache's mod_rewrite module. This is vastly superior to the older Redirect 301 directive because it allows for powerful Regular Expression (Regex) matching.

RewriteRule ^old-path/?$ /new-path [R=301,L]

The [L] flag tells Apache to stop processing further rules once a match is found, saving server CPU cycles.

2. Nginx (nginx.conf)

Nginx is built for extreme speed and concurrency. Unlike Apache, Nginx does not use distributed .htaccess files; all rules must be placed in the centralized server configuration file (usually inside the server {} block).

rewrite ^/old-path$ /new-path permanent;

In Nginx syntax, the keyword permanent triggers a 301 redirect, while the keyword redirect triggers a temporary 302.

3. Next.js (next.config.js)

For modern React-based applications, Next.js handles routing natively via Node.js. Redirects are defined as an asynchronous array of JSON objects within the next.config.js file.

Next.js expects a source, a destination, and a permanent boolean. If permanent: true is set, Next.js triggers a 308 Permanent Redirect (the modern, stricter equivalent of a 301 that explicitly forbids changing the HTTP method from POST to GET).

4. Vercel (vercel.json)

If you are deploying a static site, a Vue app, or a standard HTML project to Vercel's edge network without a custom framework config, you must manage routing via the vercel.json file. This syntax is nearly identical to Next.js, allowing the Vercel Edge Network to execute the redirect globally before the request ever reaches a server function.

The Danger of Redirect Chains and Loops

When executing a bulk migration, you must be extremely careful to avoid chains and loops. Both will trigger critical errors in Google Search Console.

Handling Query Parameters

By default, standard redirects (like Apache's Redirect 301) carry the old query string over to the new URL. If you redirect /shoes?color=red to /sneakers, the user lands on /sneakers?color=red.

If the new page does not use that parameter, this creates messy URLs and potential canonicalization issues. When writing advanced Regex rewrites in Apache, you must append a question mark to the destination (/sneakers?) to explicitly drop the old query string.


Frequently Asked Questions (FAQ)

Should I include my domain name in the Old Path?
No. In almost all server configurations (Apache, Nginx, Next.js), the redirect rule only evaluates the URI path after the domain name. For example, if the URL is `https://site.com/about`, you should only enter `/about` into the "Old Path" field. Entering the full URL will cause the rule to fail.
How long should I keep 301 redirects active?
Google's John Mueller recommends keeping 301 redirects active for a minimum of one year. However, if the old URL had significant backlinks pointing to it from external websites, you should keep the redirect active indefinitely to ensure that link equity continues to flow to your new page.
What is the difference between a 301 and a 308 redirect?
Both indicate a permanent move. A 301 is the classic standard. A 308 is a newer standard that strictly enforces the HTTP request method. If a form submits data to a URL via a POST request, a 301 redirect often accidentally converts it to a GET request, losing the form data. A 308 ensures the POST method is maintained. Frameworks like Next.js default to 308s for safety.
Can I redirect my entire website to a new domain using this tool?
While you can generate 1-to-1 page mappings here, redirecting an entire domain is better handled with a single catch-all wildcard rule. For Apache, that rule looks like: RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]. This instantly forwards every path on the old domain to the exact matching path on the new domain.

Explore More Technical SEO & Server Tools

Managing redirects is a critical server-side task. Enhance your technical SEO architecture and site performance with our suite of free developer utilities.