![]() Most redirects are 301 redirects, which indicate the old page has been permanently retired. Only the web browser sees this code it isn’t displayed to the user. The code, called an HTTP Status code, indicates, for example, whether the redirection is permanent (301 redirect) or temporary (307 redirect). It simultaneously sends a code that provides additional information. When a browser attempts to load a page that’s been configured to redirect, instead of returning the requested page the server sends the browser a new location. Who likes to go somewhere only to find it closed for business? It keeps users and search engine bots happy. Creating a 301 redirect in WordPress without a plugin.Ī redirect is a way to automatically forward a visitor, whether it’s a person or a web bot, from one page to another from behind the scenes.How do you create 301 redirects in WordPress?.When do you need to use 301 redirects in WordPress?.Guide to setting up 301 redirects in WordPress Not there yet? After this article, you will be. Every WordPress webmaster needs a solid understanding of how redirects work, why they are important, and how to set them up. 17, 2018, and was updated on March 4, 2020.ĭo you need to create a 301 redirect in WordPress? There are many good reasons to use this technique to automatically forward users (and web crawlers) from one URL to another. The second step is to open your “functions.php” file located in your theme (preferably a child theme).This post was originally published on Oct. ![]() The slug is forever! Step 2: Code in functions.php to Redirect a Page in WordPress ![]() Without the slug, all your attempts to match the URL will fail because the initial part is changing. Perhaps you’re using the HTTP protocol and one day want to move to HTTPS. Maybe you create a subdomain for a page, or move your blog into a directory. We want to insulate ourselves from potential changes. In case you’re wondering why we don’t do a simple URL matching, the reason is simple. Note the initial slash “/” in front of the slug. So for the above example, the slug will be: /test-page The “slug” is that part of the URL without the domain name, or https (or http). Once you have the URLs, create the URL slugs. It’s extremely important to know exactly how your URLs are written. To redirect a page in WordPress, we’re going to be matching strings in code. First, check and see whether URLs on your site end with a “trailing slash” or not. ![]() Step 1: Get the “From” URL Slug and the “To” URL Slugīefore we get into the code, you need to specifically write down two things:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |