A relaunch almost always changes URLs: /about-us.html becomes /company/, /product.php?id=42 turns into a readable address. For visitors, search engines and everyone who links to your pages, the old URLs are suddenly dead. Well-planned redirects make sure every old address ends up where its content lives now.
This guide walks you through the planning: from collecting the old URLs to mapping them, choosing the right status code and testing after go-live. You’ll find example rules for Apache and nginx further down.
Why 301 redirects matter
A redirect with status code 301 (“Moved Permanently”) tells browsers and search engines that the content has moved for good. That has three effects:
- Rankings: Google transfers the signals of the old URL to the new one and gradually swaps the URL in its index. Without a redirect, the old URLs return 404 and drop out, while the new ones have to earn their position from scratch.
- Backlinks: You can’t change links on other websites. Only a redirect keeps their visitors and link value flowing to you.
- Bookmarks, newsletters, print: Old links in emails, PDFs, slide decks or on business cards still lead to the right place.
Google describes the process in detail in its guide to site moves with URL changes.
Collecting the old URLs
The most common gap isn’t a wrong rule but a forgotten URL. So before the relaunch, collect from several sources and merge the lists:
- XML sitemap of the old site – usually contains all regular pages, but rarely images, PDFs or old campaign pages.
- Google Search Console: The Performance report shows which pages get clicks and impressions in search. These matter most.
- Web analytics (e.g. Matomo): pages viewed over the last twelve months, including those not linked in the navigation.
- A crawler such as Screaming Frog: finds everything that is linked internally, including files and existing redirects.
- Server logs: also reveal URLs that are only requested from outside or by bots.
- Backlinks: in Search Console under “Links” or in an SEO tool. This is where misspelled variants and ancient URLs tend to show up.
Don’t forget files: PDFs, images embedded by other sites, and feeds. Then remove duplicates and parameters that don’t change the content, such as ?utm_source=….
Mapping targets: one-to-one, not the home page
Every old URL gets the new page with matching content. A table with “old” and “new” columns is all you need, and it doubles as documentation later. The Redirect Generator turns such a list – copied straight from Excel, for instance – into ready-made rules for .htaccess or nginx and flags loops, chains and duplicates.
It’s tempting, but wrong, to send all old URLs to the home page. Visitors won’t find what they were looking for, and Google usually treats a redirect to an unrelated page as a soft 404 – as if the page no longer existed. The signals of the old URL are lost.
If a piece of content has no successor, the closest category or overview page is the better choice. If it was removed for good, the URL may simply return 404 or 410 (“Gone”). That’s more honest than a redirect to nowhere in particular.
301, 302, 307 or 308?
| Code | Meaning | Use |
|---|---|---|
| 301 | moved permanently | the standard for a relaunch |
| 308 | moved permanently, method preserved | when POST requests (forms, APIs) move as well |
| 302 | found, temporary | maintenance, short-term campaigns |
| 307 | temporary, method preserved | like 302, when POST must be kept |
The differences are defined in RFC 9110. For search engines, 301 and 308 are equivalent signals of a permanent move. For a relaunch, 301 is the usual choice. 302 and 307 mean “will be back”, so Google tends to keep the old URL in its index.
A practical tip: browsers cache 301 redirects indefinitely unless told otherwise. A faulty rule therefore sticks in the browser even after you fix it. Test new rules with 302 or in a private window first, and switch to 301 only once they work.
Chains, loops and URL variants
Every old URL should reach its target in exactly one hop. Chains appear easily when redirects from an earlier relaunch already exist (A → B) and new ones are added (B → C). Resolve them so that A points straight to C. Google does follow several hops, but each one adds latency, and at some point long chains are no longer followed. Loops (A → B → A) end in a browser error.
Also watch out for these variants of the same address:
- Protocol and host:
http://andhttps://, with and withoutwww, should be merged into a single form – ideally in the same redirect as the path change, so no chain forms. - Upper and lower case: On Linux servers,
/Contact.htmland/contact.htmlare two different URLs. If backlinks use other spellings, your rules should ignore case. - Trailing slash: Decide whether new URLs end with or without
/, and redirect the other variant straight to the right one. - Parameters: Old URLs like
/product.php?id=42differ only in the query string. Redirect rules don’t see that part automatically; you need an extra condition.
Check where your own short links and QR codes point, too. A short URL is a redirect in its own right. If it points to an old address, you get a chain. For new print material, create a new short URL that points directly to the new URL.
Example rules for Apache and nginx
For Apache, the rules go into the .htaccess in the document root, before your CMS’s rules. Many systems send every unknown URL to their index.php; if your redirects come after that, they never kick in. Individual pages come first and point to the full target URL, so even http://www. requests need only one hop:
RewriteEngine On
# 1. Individual pages – straight to the final URL
RewriteRule ^about-us\.html$ https://example.com/company/ [R=301,L]
RewriteRule ^services/webdesign\.php$ https://example.com/services/webdesign/ [R=301,L,NC]
# 2. Pattern: /news/title.html → /magazine/title/
RewriteRule ^news/([a-z0-9-]+)\.html$ https://example.com/magazine/$1/ [R=301,L]
# 3. Old URL with a parameter: /product.php?id=42
RewriteCond %{QUERY_STRING} (^|&)id=42(&|$)
RewriteRule ^product\.php$ https://example.com/products/garden-hose/ [R=301,L,QSD]
# 4. Last: merge http and www into https://example.com
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]
NC ignores case, QSD discards the old query string. If the site runs behind a proxy or CDN that terminates TLS, %{HTTPS} may always be off. Rule 4 then causes a loop, and you check the header sent by the proxy instead.
In nginx, a map keeps things tidy. It belongs in the http block, outside of server:
map $uri $new_uri {
default "";
/about-us.html /company/;
/services/webdesign.php /services/webdesign/;
~^/news/(?<slug>[a-z0-9-]+)\.html$ /magazine/$slug/;
}
# http and www: one hop to https://example.com
server {
listen 80;
server_name example.com www.example.com;
if ($new_uri) { return 301 https://example.com$new_uri; }
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name www.example.com;
# ssl_certificate … (certificate must cover www)
if ($new_uri) { return 301 https://example.com$new_uri; }
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
# ssl_certificate …
if ($new_uri) { return 301 https://example.com$new_uri; }
# … root, location, etc.
}
The exact syntax is covered in the documentation for mod_rewrite and the nginx map module.
After go-live: test and keep them
Right after the switch, check:
- Spot checks with
curl -I https://example.com/about-us.html: status 301,Locationpoints to the right target, and the target responds with 200. - The full list with a crawler in list mode: every old URL must land on a page with status 200 in a single hop.
- Search Console over the following weeks: rising 404 errors or redirect errors mean rules are missing. If you change domains, also report the move with the Change of Address tool.
After that, keep the redirects in place for as long as you can. Google recommends at least a year. But backlinks, bookmarks and printed URLs often live much longer, and a redirect costs next to nothing. Only remove them if you have a reason to.
Checklist
- Old URLs collected from sitemap, Search Console, analytics, crawler, logs and backlinks
- Each URL mapped to a matching target, no blanket redirect to the home page
- 301 for permanent moves, chains resolved, no loops
- http/https, www, case, trailing slash and parameters taken care of
- Rules placed before the CMS rules and fully tested after go-live
Tools for this topic
- Redirect Generator Generate 301 redirects for .htaccess or nginx – checked for loops, chains and duplicates.
- URL Shortener Create short URLs for free – shorten long links, with a click counter and without sign-up.
More guides
- Special characters in database passwords Why @, :, / or # in a password break your DATABASE_URL and how to encode the password correctly – for Symfony, Laravel, Doctrine and Docker.
- Which favicons does a website need? Which favicon files and sizes a website really needs today – favicon.ico, SVG, Apple touch icon and web manifest – including the HTML.
- Password-protect a directory (.htpasswd) Protect a directory or staging site with .htaccess and .htpasswd – for Apache and nginx, using secure hashing.
- Optimize images for the web Resize and compress images the right way: suitable sizes, WebP, AVIF or JPEG, quality, responsive images and lazy loading.
- Accessible colors: contrast according to WCAG What the WCAG contrast ratio means, which values apply to text and UI components and how to fix colors that are too weak.
- UUID v4, v7 or ULID as a primary key? When UUIDs make sense as primary keys, why v7 and ULID suit databases better than v4 and how to store them.
- Using JWT securely Common security mistakes with JSON Web Tokens and how to avoid them: alg none, weak keys, missing checks and where to store tokens.