banner



How To Clean 301 Redirects On Wordpress

Need to create a 301 redirect in your WordPress site? You've come to the right identify! Nosotros'll evidence you how to ready 301 redirects using four dissimilar methods. Not sure if you need to use a redirect, or whether a 301 redirect is the right ane to choose? No worries, we'll explain that too.

Redirects in a nutshell

The proper name 'redirect' pretty much says it all: Information technology sends visitors traveling to a specific page to an alternative one instead. Or, if there'due south no alternative, an HTTP header (these are similar to redirects) can make that clear to users and search engines. It'due south a bit like registering a modify of address when you lot motion firm. What if an old friend goes to your former home to pay you a visit? A redirect is like a note on the front door, telling your visitors where you're living at now. Any time that y'all change a URL or delete a folio, y'all should exist thinking about redirects.

There are different redirects for different purposes. Every bit this postal service is all virtually 301 redirects, allow'south look at some situations where yous might need to use a 301 redirect.

When should you use a 301 redirect?

A 301 redirect should be used when:

  • You've permanently deleted a page on your site, but yous have another similar page you want to send users to instead
  • You've changed the URL of a page that was already published
  • You're moving your site to a new domain
  • You're changing your URL structure, e.g. changing from HTTP to HTTPS, or removing 'www' from the start of your URL

These are some of the more than common reasons for using a 301 redirect, but there are other situations that crave using redirects, also. And besides that, at that place are other redirects and HTTP headers you can employ in other situations. For instance, if yous permanently delete a page and there is no suitable replacement or substitute you can ship users to, and then a 410 redirect is what you need to use. We've got a whole other post where yous can read more than most which redirects to utilize in which situations.

Option 1: Create a 301 redirect on the server

One of the almost basic methods of calculation a 301 redirect, is by editing your .htaccess file on the server. This method is but available on Apache servers. Nginx has its own fashion of defining redirects in the server configuration and requires extensive knowledge of organization administration.

These configurations tin get quite unmaintainable over fourth dimension, especially if you're an avid blogger or you lot're trying to improve the SEO of your posts. On top of that, yous would have to log in on your server over FTP, edit the files and re-upload them every fourth dimension you lot add a new redirect. That'south why, generally speaking, using this method is non considered the fashion to become.

Option two: Create a 301 redirect with PHP

Every bit a WordPress developer, you lot accept two options: Either you make a redirect by altering the headers of a file in the code -or- you make use of WordPress' built-in
wp_redirect function.

An example of plain PHP could be as follows:

<?php // MyExampleFile.php header("HTTP/1.i 301 Moved Permanently");  header("Location: http://world wide web.my-web log.com/a-new-destination");  ?>

Option iii: Create a 301 redirect using the built-in WordPress function

And this is how y'all'd practice the same, but at present by using WordPress' built-in function:

wp_redirect( "http://world wide web.my-weblog.com/a-new-destination", 301 );

If you forget to add the 301, both WordPress and PHP volition both assume that it's a 302 redirect, which isn't e'er the instance.

This method is a bit easier than editing files on the server, but can also get cumbersome once the amount of redirects increases.

Option 4: Create a 301 redirect the like shooting fish in a barrel style with Yoast SEO

Our Yoast SEO Premium plugin offers y'all a helping paw when it comes to creating these redirects. Our built-in redirect managing director assists you whenever yous change the URL of a postal service, folio or whatsoever of the taxonomies that may result in a possible 404 if you don't properly redirect visitors.

In addition, we too offering you an interface to edit or remove these redirects at a after point in time. The plugin too tells yous when you're nearly to create a redirect that will result in a redirect loop. This looping is something yous want to avoid at all costs.

Read more than: How to properly delete pages from your site »

Coming upwardly next!


Source: https://yoast.com/create-301-redirect-wordpress/

Posted by: sebringsittand.blogspot.com

0 Response to "How To Clean 301 Redirects On Wordpress"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel