Nightcrop
LoginGet started

How to Do a 301 Redirect: Apache, Nginx and Checks

Nightcrop · November 21, 2026

To do a 301 redirect, make your server answer the old URL with a 301 status and the new URL in the Location header. In Apache use Redirect permanent, in Nginx use return 301, and in a CMS use its redirect setting. Then test the old URL and confirm the status code is 301.

What does a 301 redirect actually do?

A 301 redirect is a server response that says a page has moved permanently. Browsers follow it automatically, and Google treats it as a signal that the new URL should be the one shown in search results. Google's redirect documentation recommends a permanent server-side redirect whenever possible for pages that have moved.

If you are not sure a 301 is the right choice, read 301 vs 302 redirect first. This guide assumes you have decided the move is permanent and you only need the how.

Before you write any rule

Three minutes of planning prevents most redirect bugs.

  1. List every old URL and its single best new URL. A spreadsheet with two columns is enough. Send each old page to the closest equivalent, not to the homepage.
  2. Point at the final address. If the new URL itself redirects, you create a chain. See how to fix redirect chains.
  3. Check the new page returns 200. Redirecting to a page that errors just moves the problem. A real 404 is better than a redirect to nothing useful.

How do you do a 301 redirect in Apache?

The Apache documentation on remapping URLs recommends the simple Redirect directive for most cases because it is simpler and more efficient than mod_rewrite. Add the permanent keyword to get a 301:

The detail that catches people: without a status, Redirect and a bare [R] flag send a temporary 302. The status has to be stated.

How do you do a 301 redirect in Nginx?

The Nginx rewrite module documentation describes two options. For a single, fixed redirect, put a return inside a location block:

Per the same documentation, a return with only a URL and no code sends a 302. Write 301 explicitly. Reload Nginx after editing, and run its configuration test first so a typo does not take the site down.

How do you do a 301 redirect without server access?

Many small sites run on a hosted platform where you cannot edit server files. Most site builders, CMS plugins and hosting dashboards have a redirects screen where you enter an old path and a new one. Look for a choice between permanent and temporary, and pick permanent. Some tools default to temporary, so do not assume.

If the platform offers no redirect option at all, Google describes meta refresh and JavaScript redirects as fallbacks. A meta refresh with a zero-second delay is read as permanent, and JavaScript is the last resort because Google may never see the redirect if rendering fails. Treat these as a stopgap and move to a platform that can send real redirects.

How do you check that a redirect works?

Do not trust that the page "ends up in the right place". Browsers hide the status code. Check it directly:

  1. Run curl -I https://example.com/old-page. The first line should say 301 and the Location line should show the new URL.
  2. Run the same command on the new URL. It should say 200 with no further Location header.
  3. Test the variants people actually visit: with and without a trailing slash, http and https, www and non-www.
  4. In Google Search Console, run the old URL through URL Inspection after a few days to see which URL Google treats as canonical. Our guide to the canonical URL explains why that matters.

Mistakes that break a 301

Frequently Asked Questions

Does a 301 redirect pass SEO value?

Google uses a permanent redirect as a signal that the new URL should be canonical, so the new page is what gets shown. Redirect to a close match; a redirect to an unrelated page gives Google little reason to treat it as a replacement.

How long does Google take to notice a 301?

It depends on how often Google recrawls the old URL. Expect days to weeks for a small site, and use URL Inspection to see what Google currently reports for a given address.

Should I use 301 or 308?

Both are permanent and Google reads them the same way for search. 308 additionally preserves the request method, which matters for form posts and APIs. For ordinary pages, 301 is the common choice.

Can I redirect a whole site to a new domain?

Yes. Redirect each old URL to its matching new URL with a pattern rule rather than sending everything to the new homepage. Keep the old domain registered so the redirects keep working.

Is a meta refresh redirect the same as a 301?

Not exactly. A zero-second meta refresh is treated as permanent, but Google recommends server-side redirects as the most reliably interpreted option.