Javascript required
Skip to content Skip to sidebar Skip to footer

Wordpress Upload 301 Redirects When Changing Urls

Need to create a 301 redirect in your WordPress site? You've come to the right place! We'll show you how to set 301 redirects using 4 different methods. Not sure if you need to use a redirect, or whether a 301 redirect is the right one to cull? No worries, we'll explain that too.

Redirects in a nutshell

The proper noun 'redirect' pretty much says it all: It sends visitors traveling to a specific page to an alternative one instead. Or, if in that location'southward no alternative, an HTTP header (these are similar to redirects) can brand that clear to users and search engines. It'due south a bit like registering a change of address when you lot motion house. What if an old friend goes to your old 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 fourth dimension that you modify a URL or delete a page, you should be thinking about redirects.

There are dissimilar redirects for unlike purposes. As this post is all about 301 redirects, let's look at some situations where you might need to utilise a 301 redirect.

When should you lot apply a 301 redirect?

A 301 redirect should exist used when:

  • You've permanently deleted a page on your site, but you lot have some other like page you want to send users to instead
  • You've changed the URL of a page that was already published
  • You lot're moving your site to a new domain
  • You're changing your URL construction, e.thou. changing from HTTP to HTTPS, or removing 'www' from the commencement of your URL

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

Selection one: Create a 301 redirect on the server

One of the most bones methods of adding a 301 redirect, is by editing your .htaccess file on the server. This method is only bachelor on Apache servers. Nginx has its own way of defining redirects in the server configuration and requires extensive knowledge of system administration.

These configurations tin get quite unmaintainable over time, particularly if you're an avid blogger or you lot're trying to improve the SEO of your posts. On peak of that, y'all would accept to log in on your server over FTP, edit the files and re-upload them every time you add together a new redirect. That's why, generally speaking, using this method is not considered the manner to go.

Selection 2: Create a 301 redirect with PHP

As a WordPress programmer, y'all have two options: Either yous make a redirect by altering the headers of a file in the code -or- you lot brand utilize of WordPress' congenital-in
wp_redirect function.

An example of obviously PHP could be as follows:

<?php // MyExampleFile.php header("HTTP/ane.1 301 Moved Permanently");  header("Location: http://www.my-blog.com/a-new-destination");  ?>

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

And this is how you'd do the aforementioned, but now past using WordPress' built-in function:

wp_redirect( "http://www.my-blog.com/a-new-destination", 301 );

If you lot forget to add the 301, both WordPress and PHP volition both assume that it'due south a 302 redirect, which isn't always the example.

This method is a bit easier than editing files on the server, but tin also become cumbersome in one case the amount of redirects increases.

Option 4: Create a 301 redirect the easy way with Yoast SEO

Our Yoast SEO Premium plugin offers yous a helping hand when it comes to creating these redirects. Our built-in redirect director assists you whenever you change the URL of a post, page or any of the taxonomies that may effect in a possible 404 if you don't properly redirect visitors.

In addition, we also offer you an interface to edit or remove these redirects at a afterward point in fourth dimension. The plugin also tells y'all when y'all're virtually to create a redirect that will result in a redirect loop. This looping is something you want to avoid at all costs.

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

Coming up next!


martenssyle1949.blogspot.com

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