Skip to content

What Is a 301 Redirect and How to Use It When Changing Domain

A 301 redirect is a permanent forwarding rule. This guide shows how to use it when you change domain: map old URLs, set rules, test them and avoid common mistakes.

9 min readUpdated Nov 28, 2026By XPASS Editorial Team

What Is a 301 Redirect and How to Use It When Changing Domain

Changing a domain is like moving house. The business is the same, but the address is new, and everyone who knows the old one needs a way to find you. On the web, the forwarding service is a redirect. When a visitor or a search engine requests an old page, the server answers with a note saying where the page lives now. The type of note matters: a 301 redirect says the move is permanent.

This guide explains what a 301 redirect is, how it differs from other redirects, and exactly how to prepare, set up and test one when you change domain. It also covers the mistakes that most often damage visibility after a move. If you want to understand which address search engines treat as the main one, read the companion guide on canonical URLs and domain choice. For the bigger question of how a company site gets noticed by Google, see how to get your company website found on Google.

What a 301 redirect is

Every time a browser asks a server for a page, the server replies with a status code. A 200 means the page was found and is being delivered. A 404 means nothing exists at that address. Codes in the 300 range mean the browser should look somewhere else. These codes and their meanings are defined in RFC 9110, HTTP Semantics.

A 301 is the status code for Moved Permanently. The server also sends a Location header containing the new address. A browser follows it automatically, so the visitor simply lands on the new page. A search engine reads the same response and learns two things: the old address is no longer the place to look, and the new address should replace it in the index.

That second point is why the 301 matters for domain changes. Links from other sites, bookmarks and search results all still point to the old domain for a long time. The redirect keeps those paths working and tells search engines how to transfer what they know about the old pages to the new ones.

The redirect types you will meet

Code Meaning Typical use
301 Moved permanently Domain change, permanent URL change, http to https
302 Found, temporary Short-term redirect, such as a maintenance page
307 Temporary redirect, request method kept Temporary move where the method, such as POST, must not change
308 Permanent redirect, request method kept Permanent move where the method must not change

For a typical website move, 301 is the standard choice and is understood everywhere. A 308 is the permanent equivalent that also preserves the request method, which matters mainly for forms and application programming interfaces. Avoid 302 for a permanent move, because it tells search engines the original address will come back, and they may keep the old one in the index.

There are also redirects done in a page itself, using a meta refresh or JavaScript. These are slower, depend on the page loading first, and are not the right tool for a domain change. Use server-side redirects.

When to use a 301

Use it whenever an address has a new permanent home.

  • You are moving to a new domain, for example after a rebrand.
  • You are changing from http to https.
  • You are choosing between www and non-www and want only one to be reachable.
  • You are consolidating several domains you own into one primary domain.
  • You are changing page paths, for example restructuring categories.
  • You are merging two pages into one.

Do not use a 301 to hide pages you simply deleted. If a page is gone and has no equivalent, a not-found or gone response is more honest. Forcing everything to the home page confuses both visitors and search engines.

Before you start: plan the move

A domain change is easier when planned. The guide on changing domain while keeping your SEO ranking gives a wider checklist, and the main steps for redirects are below.

  1. List your current addresses. Export the pages from your site, your sitemap, your analytics and Search Console so you do not miss any that carry traffic or links.
  2. Decide the new structure. If addresses on the new domain keep the same paths, mapping is trivial. If paths change, you need a table.
  3. Build the mapping table: one row per old address, with the exact new address next to it. Aim for one-to-one matches. For pages without a counterpart, choose the closest relevant page, or accept a not-found response.
  4. Make sure the new domain is registered, its DNS points to the right server, and a valid certificate covers it. You can check your name options on the domains page, and the SSL certificates page explains how certificates cover the names you use.
  5. Keep the old domain registered and its DNS working. The old domain must keep answering requests, otherwise the redirects have nowhere to run. Renew it for as long as you want the redirects to exist.
  6. Prepare the new site completely before switching, including content, internal links, canonical elements and a fresh sitemap. The article on sitemap XML and domain setup explains the sitemap side.

How to set up a 301 redirect

The mechanism depends on where the old site is hosted. Here are the common approaches.

On a web server

The redirect belongs in the configuration of the old domain. In a typical web server, you give the old hostname a rule that sends any path to the same path on the new hostname with a 301. The nginx server, for example, can express this with a single line inside the server block for the old name:

return 301 https://new-example.com$request_uri;

On Apache, a rewrite rule in the configuration or the access file does the same job for every path. The important feature is that the path and query string are carried over, so an old page lands on its matching new page rather than on the home page.

Page by page when paths change

If paths on the new site differ, add specific rules above the general one. A single page can use a simple redirect statement, such as this Apache directive.

Redirect 301 /old-services https://new-example.com/what-we-do

For a large number of pages, use a map file or the redirect manager of your content system instead of hand-written rules.

In a content management system or hosting panel

Many website platforms and hosting control panels provide a redirect screen where you enter the old address and the new one, and choose permanent. This is a good option if you do not manage the web server directly. Check that the tool allows wildcard or whole-domain rules, so you do not need to enter thousands of lines.

At the domain level

Some domain providers offer a forwarding feature for the bare domain. It is acceptable for a simple case, but confirm it sends a 301 and carries the path across. If it only sends visitors to the home page, it is not sufficient for a site with many pages.

Testing the redirects

Never assume the rules work. Test them.

  1. Open a handful of old addresses in a browser, including the home page, a deep page and a page with a query string. Confirm each one lands on the right new page.
  2. Use a command line tool that prints response headers, or a browser developer tools network tab, to confirm the status code is 301 and the Location header is the exact new address.
  3. Check for chains. An old address should reach the final address in one hop. If it goes old, then http, then https, then new, fix it.
  4. Check both http and https versions of the old domain, and both with and without www. Visitors may arrive through any of them.
  5. Test the new site itself for broken links, missing images and mixed content warnings.
  6. Run a crawl or review your analytics for the old addresses that still receive traffic and make sure they are covered.

A plain example

A design studio operates at oldstudio.example and decides to rebrand to newstudio.example. It has 120 pages: a home page, a services section, a portfolio, a blog and a contact page.

The owner exports the page list and finds that the blog and portfolio keep their paths on the new site, while the services section is renamed from /services to /what-we-do. The mapping is simple. One general rule sends every old path to the same path on the new domain. Above it, one specific rule sends /services to /what-we-do. The two old pages that were deleted during the redesign are mapped to the closest relevant pages.

The studio keeps the old domain registered, points its DNS to the same server, and installs a valid certificate that covers the old name, so that visitors arriving over https do not see a warning before the redirect happens. After launch, the owner registers the new domain in Search Console, submits the new sitemap, and uses the change-of-address tool for the old property where available. Over the following weeks the owner checks reports for errors, fixes a few redirects that landed on the wrong page, and compares traffic with the figures from before the move.

Common mistakes

  • Redirecting everything to the home page. Visitors who clicked a link to a specific article land on an unrelated page, and search engines may treat it as a soft not-found.
  • Using 302 for a permanent move. The old address may stay in the index longer than you want.
  • Creating chains and loops. A redirect that points back to itself, or through several steps, slows pages and can break them entirely.
  • Letting the old domain expire. When the registration lapses, the redirects stop, and someone else may register the name.
  • Forgetting the certificate on the old domain. Visitors on https see a warning before any redirect can happen.
  • Forgetting subdomains, such as blog.oldstudio.example, and other hostnames that used to serve content.
  • Forgetting non-page files, such as PDF documents and images, that other sites link to.
  • Changing content at the same time as the domain. Moving and redesigning together makes it hard to tell what caused a change in traffic. Keep the move as plain as possible, and redesign later.
  • Not updating internal links. Internal links should point straight to the new addresses rather than relying on redirects.

Limits and what to watch for

A redirect is a bridge, not a permanent solution. Search engines usually transfer most of the old pages' signals to the new ones, but it takes time, often weeks or longer, and temporary fluctuations are normal. No guide can promise that a ranking will be unchanged.

Redirects also add a small delay for each request, so keep them to one hop and fix internal links to avoid depending on them. Keep the redirects for at least a year, and longer if the old domain still receives traffic or links. Check logs periodically to see whether old addresses are still being requested.

Remember email. If your old domain carries mailboxes, changing the website does not require moving the mail, but DNS edits can disrupt it. Keep the existing mail records intact while you adjust the web records, and plan the mail move as a separate step if you want to change addresses there as well. The business email page is the right place to look when you set up mailboxes on the new domain.

Finally, a redirect does not fix poor content or technical problems on the new site. Search engines still judge the new pages on their own merits.

Summary

A 301 redirect is the standard way to tell visitors and search engines that a page has moved permanently. When you change domain, map each old address to its closest new equivalent, set server-side 301 rules that carry the path across, keep the old domain registered and covered by a certificate, test every rule for status code, destination and chains, update internal links and sitemaps, and watch Search Console afterwards. Keep the redirects in place for at least a year and avoid changing too many other things at the same time.

If you are choosing the new name for your site, the domains page is a good place to start.

Frequently asked questions

What is a 301 redirect?

It is an HTTP response telling browsers and search engines that a page has moved permanently to a new address. The visitor is sent to the new address automatically, and search engines learn to treat the new address as the replacement.

What is the difference between 301 and 302?

A 301 means the move is permanent. A 302 means it is temporary and the original address is expected to return. When you change domain for good, use 301. Use 302 only for short-term situations such as maintenance.

Should I redirect every old page to the new home page?

No. Redirect each old address to its closest equivalent on the new site. Sending everything to the home page loses the connection between pages and often looks like a mistake to search engines.

How long should I keep the redirects?

Keep them for as long as you reasonably can, and at least a year. Old links, bookmarks and printed material keep arriving long after the move, so there is little benefit in removing the redirects early.

Will a 301 redirect keep my ranking?

A correctly mapped redirect lets search engines carry over the old pages' signals to the new ones, but small temporary movements in ranking are normal and no result can be promised. Content, links and technical health still matter.

About the author

Bob Kanokphon Thongdee, founder of XPASS VPN

Bob Kanokphon Thongdee

  • Founder of XPASS VPN
  • Co-founder of eSIMonline.asia
  • More than 7 years in online marketing
  • Founder of Cojourney Visa and Cojourney Travel

Start your website the right way

Register a domain, add SSL and set up business email from one place.

.com registration from $18.81 for the first year

Start with a domain

Keep reading

Website Guides

What Is a Canonical URL and How Does It Affect Domain Choice?

A canonical URL names the preferred address when several URLs show the same page. Learn how it relates to your domain, www, HTTPS, redirects and sitemaps.

9 min read

Website Guides

How to Get a Company Website Found on Google: Where to Start

A step-by-step starting point for making a company website easy for Google to find: domain, HTTPS, indexing, sitemap, content and measurement.

10 min read

Website Guides

What Is a Sitemap XML and How Do You Set It Up for Your Domain?

A sitemap XML lists the pages you want search engines to find. See how to build one, tie it to the right domain and submit it correctly.

10 min read