You changed a page’s address, deleted an article or switched domain. Anyone holding the old address (in a bookmark, a search result, a link on another site) now lands on a 404 error. A 301 redirect fixes that: it tells the browser, and search engines, that the page has moved for good and where to.
301 or 302?
| Type |
It means |
Use it when |
| 301 |
Moved for good. |
You changed a page’s address, changed domain, moved to HTTPS or decided to always use www (or not). |
| 302 |
It is elsewhere for now. |
A temporary page, a promotion that ends, a short maintenance. |
If you are torn between the two, ask yourself whether the old address will come back. If it will not, it is a 301.
Three ways to do it
| 1 |
With cPanel’s Redirects tool, in the Domains section. You pick the type (permanent is the 301), the old address and the new one, and the panel writes the rules for you. It is the safest road for anyone who does not want to touch files.
|
|
| 2 |
In .htaccess, one page at a time, above the WordPress block:
Redirect 301 /old-page/ https://yourcompany.com/new-page/
|
|
| 3 |
In .htaccess, for a whole domain, sending every address to the same address on the new one:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?theold\.com$ [NC]
RewriteRule ^(.*)$ https://thenew.com/$1 [R=301,L] Swap the names for your own. The HTTPS rules are in redirecting HTTP to HTTPS with .htaccess.
|
|
On a WordPress site there are also redirect plugins. They help when there are many addresses or when you would rather manage everything from the dashboard. If you rename a post, WordPress usually deals with the old address by itself; do not count on that when you change the whole link structure.
Checking that it works
| 1 |
Open the old address in the browser, in a private window. It must end up on the new one.
|
|
| 2 |
See the code the server returns. In a terminal, curl -I followed by the old address shows the status (it should be 301) and the location line with the destination. Online tools do the same.
|
|
| 3 |
Count the hops. From old to new it should be one. Every extra hop slows the visitor down and is a place where the chain can break.
|
|
Three mistakes that cost dearly. Sending every old page to the home page: the visitor does not find what they wanted, and search engines treat it as if the page had vanished. Making chains (A to B, B to C): point A straight at C. And writing a rule that sends an address to itself, which gives the “redirected too many times” error. Keep a copy of .htaccess before you touch it.
|
|
Keep your redirects as long as you can. While old links are still circulating, they are what gets those links to you. If the redirect is for a domain, do not let the old one expire: see every step of a domain move.
|
|
Do your redirects fail on the server side (a 500, a loop, a rule that does not take)? Send us the old address and what appears.
Open a support ticket
|
RECOMMENDED PRODUCT Register your .com domain Secure your company name before someone else registers it. from £13.60/yr Search a domain |