If you’ve moved in the past, you’re probably familiar with how your local post office handles your mail. You give them your new address, and they automatically forward all your letters, bills, and (ugh) junk mail to the new location.
When you want to move something in your online store, it doesn’t seem so simple. There’s no post office to notify, no sticker to put on your page that directs traffic to a new location. It’s much more complicated… right?
It is, in fact, very easy to move things around in your online store — if you know how. If you want to learn to redirect traffic from one page of your site to another, this post is for you. We’ll be discussing how to use URL redirects to shuffle traffic from one page to another. It takes just a little time and effort, and you won’t even have to call the post office.
Let’s explore how eCommerce redirects work, when you should use them, and how you can set them up on your site.
A URL redirect does exactly what it sounds like: when you enter a URL into your browser or click on a link, it directs you from your initial location to a different destination.
The way redirects actually work is a little more complex. You’re probably familiar with the “404 not found” error, right? Well, there are similar codes, like that 404, that tell your browser what the status of a redirected URL is — whether it’s gone forever or just temporarily missing — and what to do next.
The currently used/recommended redirect codes are:
- 301 — permanent redirect (the first URL isn’t coming back)
- 303 — see other (you’re being moved to a new URL, just wait a moment)
- 307 — temporary redirect (the page you want has temporarily moved to this location)
There are a few other redirect options, including 302 (temporary redirect) and 308 (permanent redirect), but the former has been phased out and the latter has not yet been adapted.
99% of the time, your store is going to need a 301, or permanent, URL redirect. As such, that’s what we’ll be focusing on in this guide: when you might need permanent URL redirection, and how to set it up.
When your online store might need a redirect
Let’s say you have a popular product. Over time, its page accumulates a lot of links from other sites. But after a few years, you need to replace this product with a new version.
You don’t want to lose those links, or the potential customers that come with them. But you do need to create a new page for the new version of this product, so using the same URL is out of the question.
This is the exact type of situation that a 301 redirect was created for!
With a 301, or permanent, URL redirect, you can send everyone who visits the link for your old product page to your new one automatically. Any potential customers who click the link will almost instantly land at your new page, without seeing any 404 errors or waiting more than a second or two.
You might need a redirect in a variety of other situations, too, including:
- When a product has been removed and you want to direct traffic to a similar item instead
- When you’ve removed a special landing page (for a sale, contest, etc.), and just want the traffic going to your homepage
- When you’ve consolidated multiple product pages into one (for example, with variations) and are left with multiple outdated URLs
- When you’ve changed your store’s URL structure entirely
Basically, if you’ve removed a URL and it’s never coming back, it’s time for a redirect. That traffic has to go somewhere, after all.
When you need a redirect, and when you can go without
At this point you might be wondering “do I always need to redirect my URLs? What if I make a typo and change it right away?”
Redirects are only crucial if the initial URL has been widely visited, bookmarked, linked to, or referenced in external materials (for example, in marketing or other promotions). While a 404 certainly isn’t a good experience for your store’s visitors, one or two potential dead links is sometimes better than spending several minutes of your time setting up a redirect no one will use.
So if you make a typo in a product page URL and immediately fix it, don’t worry about the redirect. But if you make a typo and only catch it a few weeks later, you should probably create the 301.
One final note: some platforms, including WordPress, will attempt to redirect any changed URLs automatically. This likely won’t apply to any major changes (for example, changing the structure of your permalinks in WordPress after publishing a few dozen pages), but it’s worth looking into the next time you make a minor URL alteration.
How to implement a redirect for your eCommerce website
Now you know what redirects are, and when you might need one. You’re ready for the next big step: learning to implement one.
There are multiple ways to implement a redirect for an eCommerce website, and they vary both by platform and hosting environment. We’ll cover some of the most common here, starting with how you can set up redirects if you’re running WooCommerce.
Redirects with WooCommerce or WordPress
As mentioned above, WordPress will attempt to automatically handle basic URL redirections for you — for example, if you change the title of a product page in WooCommerce, and with it the permalink. However, major redirects aren’t handled, so anything like a category change or alteration in permalink structure will need to be handled manually.
If you’re not opposed to adding another extension to your WooCommerce store, you can set up 301 redirects in a matter of moments by installing one. Redirection is one of the most popular (and free) plugins for creating URL redirects within WordPress.
Just enter the source (old) URL, the target (current) URL, and click “Add Redirection.” That’s it — you’re done.
Redirection also keeps track of your store’s 404 (“not found”) errors, which can alert you to potential redirects that might need to be created. It also has built-in statistics, so you’ll also be able to see how many times your redirects have been used.
Redirects for self-hosted platforms using the .htaccess file
Don’t want to add another plugin, or are you not using WooCommerce? No problem.
If your store is self-hosted and you have access to your server, you can set up URL redirects by editing your .htaccess file. This is a simple file that applies global configuration settings to your server. It’s also where you can set up URL redirects by hand.
You can check for this file by accessing your server’s public_html directory via FTP or File Manager. If you don’t see a .htaccess file, you can create one using your text editor of choice. Name it .htaccess (with no extension) and upload it to public_html.
Having said that, you should always make sure you don’t already have an .htaccess file first. If you’re using WordPress, you should have one already. When you open your File Manager, look for options below that allow you to “Show Hidden Files” or “show dotfiles”:
Either way, once you create or open your .htaccess file, you’ll be ready to add your first 301 redirect. The easiest route will be to edit it via your server’s File Manager (using the built-in Code Edit option, if available), or you can always open it with your local text editor of choice.
WARNING: Always back up your .htaccess before making any edits, especially if you are unfamiliar with this file.
When you add new redirects, they should be formatted like this:
# Place your comments here
Redirect 301 /oldurl.html http://www.site.com/newurl.html
Each new redirect should be on a new line. Comments can be added, and should be marked by a pound sign (#).
Save your file, upload it if necessary, and test the redirect in your browser. If the redirect works, fantastic! If something seems out of place, take a look at the example above and give it another shot.
Note that if you’re doing this process for a WordPress site or WooCommerce store, your redirects should be placed above the WordPress code, as shown above. (Hat tip to Damien for noting the importance of this in the comments!)
Some store owners won’t have access to .htaccess, including:
- Those who use a hosted eCommerce platform
- Anyone not on an Linux hosting environment, i.e. using a Windows server
- Clients of certain hosts who have blocked the ability to access, edit, or create this file
If you’re in one of these situations, you’re not out of luck. However, you’ll probably have to consult your platform and/or your host to find out the best way to implement 301 redirects.
In many cases, hosted platforms have an option for URL redirects built right in, although it might be a little difficult to find. As for you Windows users, give this resource from Microsoft a try — it walks you through creating redirects with IIS.
The danger of not implementing proper redirects
If you discontinue products frequently, this redirection thing might sound like a lot of work (and it is). So you might be thinking “can’t I just let those links 404? Won’t my visitors just go to my homepage?”
There are two really, really big problems with not setting up redirects for removed URLs:
- It creates a poor experience for your visitors, which over time can make the situation…
- … absolutely terrible for your store’s search engine optimization (SEO)!
Think about this: if you search for a product, click a link from Google, and get a 404, you’re probably going to be annoyed. You might stay on the site and look for the correct link… or you might leave immediately and try another site instead.
This doesn’t just mean a loss in sales — it also means a loss in rankings. User behavior has a compounding effect on your site’s SEO. Google notices when users do U-turns, and it doesn’t want to highly rank the sites that cause them.
So if you have a lot of old links that don’t redirect to new ones, and the visitors coming from search are constantly getting annoyed and leaving, your rankings are going to slip.
While Google says that 404 errors won’t impact your search engine rankings outright, they can certainly have a snowball effect over time. And more importantly, you don’t want to upset your potential customers. So it’s best to take the time and set up redirects where they’re needed, as soon as they’re needed, rather than face the consequences of slipping in the rankings.
Set your customers straight with URL redirects
There you have it — your own virtual equivalent to the post office’s address forwarding. Now you’ll be able to get your visitors moving in the right direction when they visit your site, no matter how old your URLs are or where they used to point.
Do you have any questions about implementing redirects in your store? Any recommendations you’d like to add for our readers? Let us know in the comments below, we’re always eager to hear from you.
Header image credit: DaveBleasdale
With the .htaccess solution, I always put the Redirect lines before the “# Begin WordPress” block. This allows WordPress’ index.php receive the new url, which it will know how to handle.
Good call Damien! This is correct — I’ll update the screenshot and the post to make that clearer.
Nicole, nice in-depth post on redirects – what do you consider best practice for products that have been removed that you don’t have a related replacement for but have acquired lots of links to that product page?
That’s where it gets tricky. From both a SEO and a user standpoint it makes the most sense for the replacement link to be as similar as possible, otherwise you stand to confuse visitors (“why am I on a completely unrelated page?”) or lose the rankings you’ve built up.
There are a couple things you can do:
1. Create a landing page or even a non-buyable product at that URL explaining the situation and offering a solution or two (“This product has been removed, but here are a few other options…”)
2. Redirect that traffic to your homepage/a category page/etc, BUT use a solution that allows you to show a special message/popup if the referral URL is your now-dead product page link indicating what happened (there are a couple plugins out there that might let you do this)
3. 404 it
From what I recall, the 404 is best if you have a lot of search engine traffic coming in for a query and the page is gone now. But if you have a lot of links/customer engagement one of the first two is better.
Here’s a Moz Q&A thread on that topic: https://moz.com/community/q/should-i-implement-301-redirects-vs-410-in-removing-product-pages
here is another one: How about, if I redirect an outdated product in my shop to, let’s say an amazon-affiliate-link-product, because I don’t sell it myself anymore, but want to provide that link anyways.
What would customers think about it, coming from another site, expecting to visit my shop? And what does google think about it. Will it be bad for the websites that linked to my shop, because it is a redirecting affiliate-link?
This is not meant, to be some kind of spammy trick at all, as you might think now… But we would like to make use of it every once in a while, anyways.
Do you think it’s ok!?
Hey Boris, another great question!
From a customer standpoint, it could be a LITTLE surprising if they aren’t expecting it. I’ve personally seen a couple shops set up product pages where the “buy” or “add to cart” button is replaced with a “purchase on external site” button instead, which then redirects the visitor to the external site or through the affiliate link. I like this approach and I think it’s the most user friendly. You can do this in WooCommerce by adding an “external” product: http://docs.woocommerce.com/document/managing-products/#section-7
From a SEO standpoint, Google’s not always fond of affiliate links/websites because they don’t necessarily present a great user experience. Typically they have thin content, aren’t well-designed, etc. Not saying this is always the case, of course, but you get the idea. 🙂 So an automatic 301 redirect to an external/affiliate site could impact your rankings, especially if you don’t have the same quality content on that external site.
There are a few tutorials around about how you can handle affiliate links by “cloaking” them, but ultimately the first approach (if you’re using WooCommerce) and the external product type/being crystal clear with your customers is the best way to go from a user standpoint. If it’s not something you’re going to do a lot, that’s going to be your best solution.
How would one redirect many (all product) pages in case you’ve changed your Woocoomerce product permalinks from yourstore.com/term1/term2/term3/product to yourstore.com/product-category/product ? Is there some kind of wildcard placeholder that would let me redirect all traffic that comes in at /term1/term2/term3/ to /product-category/ without specifying the exact URL for every product?
Hey Andre, this is getting into some more complex .htaccess stuff but there is indeed a way to do it.
This is a pretty straightforward guide: http://coolestguidesontheplanet.com/redirecting-a-web-folder-directory-to-another-in-htaccess/ You’d be looking at the section labeled “to redirect a whole directory.”
Hope that helps!