Do You Even 301, Bro?
If we’re being really honest, writing 301 redirects is boring. Alright, it downright sucks. Knowing differences between 301 redirects and 302 redirects is kinda important. But, writing redirects isn’t nearly as bad as losing all the SEO value of pages that Google and other search engines have already indexed!
This post is here to make writing 301’s suck a little less and to help you come up with a decent redirect strategy for the website you’re working on.
First, let’s define the difference between a 301 and a 302, just to make sure we’re all on the same (web)page.
- A 301 redirect will send visitors and search engines to the new destination permanently.
- A 302 is a temporary redirect that indicates you only want visitors to be sent to a different page for a short period of time.
*Google has said that both 302 and 301 redirects both pass PageRank, but there is a debate within the SEO community. Use a redirect based on their intended purpose so you don’t cause problems later. If you want a permanent solution, use a 301; if you want a temporary solution, use a 302.
Pretty simple, right? Cool. Let’s move on.
301 redirects and 302 Redirects Requirements
- Screaming Frog SEO Spider w/ valid license key
- A text editor, such as Sublime.
- Redirection WordPress plugin.
Get a List of All Existing Pages
First, we need to get a list of every page on the production site.
- Configure Screaming Frog to crawl internal links only. You’ll also want to turn off screenshots/rendering so you don’t waste time crawling a bunch of crap on a website you don’t care about.
- You should choose a spot to keep your Screaming Frog configurations and extract the file there.
- You can load the configuration in Screaming Frog under “File > Configuration > Load Configuration”.
- Once you’ve got Screaming Frog configured, type in the production URL and let the site crawl begin.
- Once the crawl is finished, save the results (“File > Save”) This is important. Should you find yourself needing a list of every page that did exist on a site, you can Load this crawl data.
- Filter the results down to Internal HTML pages only.
- You can do this via the “right sidebar”, under “Internal > HTML”.
- Highlight every single address listed in the results and copy (CMD+C).
- Paste the copied addresses into your text editor.
Crawl the Resulting Addresses on the Sandbox
Next, it’s time to crawl all the resulting addresses. Here at TM, we set up a sandbox website where we get to play around before pushing everything live. If we break something, no harm no foul – it wasn’t on the live site!
- Run a “Find/Replace” to replace the production address with the sandbox address.
- In this example, we would replace “www.example.com” with “example.tmsandbox.com”.
- Select & copy all of the new sandbox URLs (CMD + A & CMD + C).
- Back to Screaming Frog & clear the current crawl results.
- Click “Mode > List” in the Screaming Frog menu bar.
- Click Upload where the address bar used to be, then select “Enter Manually”.
- Paste the copied sandbox URLs and begin the crawl.
Evaluate the Results
- At this point, you know what pages require a 301 redirect if they return a 404 response*.
- You can apply a filter to only show 404 pages in the right sidebar under “Response Codes > Client Error”.
- Similar to the first step, copy the addresses of all the 404 pages and paste them into a text editor.
- This time run a find/replace to remove the request protocol and sandbox domain name altogether.
- In this example, we would replace “http://example.tmsandbox.com” with an empty string.
*A 404 is an error message displayed by a browser indicating that an Internet address cannot be found.
Write the 301 Redirects
With a list of URL’s that will 404 on the new site, you’re ready to start writing the 301 redirects. In this next step, you’ll use Google Docs, because it’s stupidly easy. It’s how we do it here at TM.
- Open Google Docs & login with your Google account.
- Go to Google Sheets.
- Create a new spreadsheet from the “301 Redirect Template”.
- Paste all the paths from your text document into the spreadsheets first column under the Source URL.
- Enter a relative rewrite path to in the 2nd column.
- Once you have provided a rewrite path for each URL, click File > Download As… > CSV.
Import the Redirects
- Log into the WordPress admin.
- Make sure Redirection is activated.
- Go to Tools > Redirection.
- Toward the bottom, you’ll see “Import”.
- Choose the File & then click Upload.
Test the Redirects
Lastly, you just need to make sure the work you’ve done is working.
- Return to Screaming Frog. You should still have the sandbox crawl results filtered to only show 404 response codes.
- Highlight all the visible results, right-click and select “Recrawl”.
- Addresses that disappear from the 404 list have successfully redirected.
- Any results that do not disappear were not redirected correctly.
- Crawl the entire sandbox once more, to ensure there are no 404 response codes.
If there no 404’s, all addresses were successfully redirected.
Congratulations! You are now a master of 301 redirects and 302 redirects! Now you should learn more about what’s in an SEO audit and howto apply all this awesome redirect knowledge!