URL Redirection is a mechanism for redirecting site visitors from one domain or page to another. It is possible to redirect your visitors to any web page on the internet, but it is most commonly used to reroute them within the same website. When a user enters a URL or clicks a link to Page A, you may redirect them to Page B instead.
It is not optimal to set up redirects. It slows down the user's experience since the browser will go to the first URL, receive the redirect message, and then proceed to the second URL. And there's a chance you'll set up the redirect incorrectly or just forget to do it after altering a URL. Unfortunately, Google missed the notice and continues to direct users to your non-existent page. What are we going to do about it? The ideal option is to utilize a 301 redirect to transfer people to another page that contains the information they need. If it doesn't already exist, make it! By receiving clicks in the SERPS, the page is obviously doing something well. You must capitalize on it.
In most cases, this entails installing a plugin in WordPress to redirect a page. While this is not a bad idea, it is overkill if you only want to redirect one or two pages. Using a code inserter or the functions file in your themes directory. Configure your permalink settings to utilize beautiful permalinks when you initially set up your site and before you add any articles or pages to minimize altering URLs.
In this article, we will explain to you how to redirect a WordPress page without a plugin.
One of the first things you have to know about when learning how to redirect a WordPress page without a plugin is about the .htaccess file.
The .htaccess file is one of the most crucial files on a website. Because HT stands for hypertext access, it stands to reason that you may use it to accept, reject, or divert access to your site. While it may appear scary due to how critical it is that you do not make any mistakes, the actual altering of the file to redirect is as easy as it can be.
To access the root directory of your WordPress installation, use your preferred FTP software. .htaccess should be found just beneath the main directories. Open this with a text or code editor of your choice. To create a WordPress redirect, just add a line of code right above the line that reads # BEGIN WordPress.
Either of these lines of code will route your whole website to the chosen URL. If you wish to redirect a certain page, post, or URL on your site, you must give both the source and destination URLs. Both can be the relative path (assuming you stay inside the same domain) and are separated by a single space.
When you wish to redirect a group of URLs that share specific elements, use a wildcard redirect. This is also important when wanting to redirect a WordPress page without a plugin. For example, if you alter your permalink structure, a wildcard redirect will redirect everyone who uses a link from your old structure to the identical link in your new structure.
If you change your post permalink structure from /blog/post-name to /category/post-name, for example, you'll need to employ a wildcard redirect to guarantee that anybody using the old links gets diverted to the new URL. Wildcard redirects make advantage of a feature known as Regex, which allows you to build sophisticated redirects. To set up a wildcard WordPress redirect, you must first activate Regex functionalities.
Scroll to the Add new redirection area of the screen by going to Tools > Redirection. Enter the old route to categories as a wildcard in the Source URL box. It must be in the format /oldslug/(.*)$. The Target URL entry must include the source /newslug/$1. Then select the Add Redirect option.
Often the WordPress redirect plugin will miss the page redirect you require. Perhaps you want to redirect one article on your WordPress site to another, or you want to redirect a URL on your domain to a different website. This is why it is useful to learn how to redirect a WordPress page without a plugin.
In this instance, you'll need to set up a manual redirect in WordPress without the use of a plugin. Scroll down to the Add new redirection area under Tools > Redirection.
Type or paste the URL you wish to redirect from into the Source URL area. Enter or paste the URL you wish to redirect to in the Target URL area. If you're redirecting from an older post to a later one, leave the Group option as Redirections (the default) or choose Modified posts. This will provide browsers with information about the kind of reroute. When you press the Add Redirect button, your custom redirect will be added to the list of redirects.
This solution is ideal if you do not want to utilize a plugin to redirect URLs and use cPanel hosting. The procedure is really straightforward. Navigate to your hosting account's cPanel and choose "Domains" > "Redirects." You should see a screen similar to this one, with various options to pick from. You must pick the type of redirection you wish to do in the "Type" selection box, whether permanent (301) or temporary (302). (302). It should be simple to pick between the two choices depending on the link you want to redirect to.
Select your domain + current page address from the second dropdown menu. After that, in the last field, write the web page address, which should replace your existing page address. You're done when you click "Add."
If your website uses Cloudflare, you may also do the redirection from there. Simply log in and follow the simple procedures outlined below:
Click on the domain to which you want to redirect links from the homepage. Click on one of the top tabs labeled "Page Rules." Select the “Create Page Rule” option.
This dialog will appear. Fill up the first field with your chosen URL. Then, under the settings, select “Forwarding URL” and either 301 or 302 redirect as needed. Finally, type in your target URL. Once everything is filled out, click "Save and Deploy" to finish the task.
Firstly, add the redirect code function, and then this code checks if the user is on the about page, and if they are, they are routed to the home page.
You may alter this to check for any other page by changing the ‘about' string, which checks if the user is on the about page. For instance, we may change the code to check if the user is on the contact page.
You'll need to set up a redirect if you alter the URLs on your WordPress site or publish a new post to replace an old one. You may use an automated redirect, a manual redirect, or a wildcard redirect depending on the modifications you've made. I hope you learned how to set redirects for various situations from this post.
If you enjoyed reading this article on redirect a WordPress page without a plugin, you should check out this one about WordPress briefly unavailable for scheduled maintenance error.
We also wrote about a few related subjects like failed to open stream error, WordPress post missed schedule, failed to load resource error, WordPress posting to Facebook done automatically, Wordpress mixed content errors, how to reorder pages in WordPress and WordPress updating failed error.