Looking to learn about how to redirect a WordPress Post or Page Without a Plugin including redirect types and their meaning? You’re in the perfect place.
301 redirect is pretty simple – It’s used to redirect one page to another to ensure your visitors get sent to the right place.
It’s very important in SEO too, guess you’re having a post that having tons of backlinks and for some reason, you want to change the URL of that article – may be URL is too long or any keyword missing in it. But once you change the URL, you would lose all backlinks that linked to the post. In such a case, 301 redirect comes as it’s used to redirect the old URL to a new URL without losing any backlink and ranking.
How to Quickly Redirect by Using a Plugin
While this post talks about redirecting without a plugin, let us show you how to do it by using WP 301 Redirects, an amazing plugin that will solve all your redirecting problems.
So, WP 301 Redirects provides you with solutions for old and bad links, any possible typos in your links, and loss of traffic. Your links will never again link to nonexistent or wrong pages. With this plugin, you will regain control over all your links and assure your website is getting all of the valuable traffic.
Moreover, users won’t see the 404 page, but rather get redirected to the page they actually wanted to see. You will also be pleased to know that bots won’t be able to go to those pages. WP 301 Redirects ignores bad bots and shows them the wrong page. Plus, the plugin will allow you to scan and verify each link to assure it’s working smoothly.
Finally, WP 301 Redirects lets you get the information you need about the performance of your website by providing you with built-in charts. Also, in case of any confusion, you can always contact support which is never outsourced, so you can be sure you will get answers from the team that made the plugin.
Redirect a WordPress Post or Page Without Plugin:
So in this article, we’re going to discuss 2 methods to redirect WordPress posts without a plugin. Also, you can use a redirection plugin to get the job done. Again, it all depends on our usage – if you only want to redirect 2-3 URLs or very rarely in the future then it’s better to get the job done without a plugin.
So let’s dive into it…
Method 1: Redirect WordPress Post or Page Using .htaccess
Maybe you heard about .htaccess – if not, no issue. The .htaccess file is a configuration file that handles how a web server responds to various requests. It’s commonly used for redirecting URLs, enabling password protection, and many advanced configurations.
This .htaccess file located in your root directory, you can see in the below screenshot. You can either find it through File Manager on your host or you can use FTP software to find it.
Note: Your .htaccess file starts with a dot because it is a hidden file. So if you don’t see it in your root folder, make sure that your file manager isn’t keeping those files hidden from view.
Once you find your .htaccess file, you can edit and add the redirection rule. But make sure you handle this file carefully, one slight change in code can break your site.
Nothing to worry, if you follow the exact steps.
Open the .htaccess file and you will see this screen if you haven’t touch .htaccess before.
Now just paste the below rule before # END WordPress or in an open space.
Redirect 301 /old-post/ http://yoursite.com/new-post/
This rule will redirect http://yoursite.com/old-post/ page to http://yoursite.com/new-post/
You can add as many redirect rules as you want – just make sure you place them one by one and save them once you have done.
You might be wondering why I place the only slug, like /old-post/ and later whole URL. The reason is simple to avoid effect in the redirection. Because maybe in the future, you would like to move your site from HTTP to HTTPS or adding a subdomain later.
That’s why if we only put slug so any redirection rule will match even if anything changes in the initial part.
Method 2: Redirect WordPress Post or Page Using functions.php
Another way to redirect the WordPress page with the help of functions.php.
To redirect your entire site to a new URL, you can paste below code to your functions.php file that is located in your active theme directory.
The code is:
wp_redirect( 'http://www.mediumtalk.net', 301 ); exit;
Note: Replace “http://www.mediumtalk.net” with the new URL that you want to redirect to.
Once it has done, every page or post will redirect to a new URL instantly.
However, You may face the problem while adding code directly through Theme Editor like below.
In such a case, use FTP or File Manager to edit functions.php.
You can also add conditions tags to redirect the WordPress page. Like if you want to redirect some page to a different page – then you can use below code
add_action('template_redirect', 'redirect_to_home_from_about_page'); function redirect_to_home_from_about_page() { if( is_page('about')) { wp_redirect(home_url()); exit(); } }
This code will redirect all users to the Homepage if users landed on the About page. In the same case, you can replace about or homepage with any other page.
Wrapping up:
Whether you’re planning to move your website to another URL or want to redirect an old URL to a new URL, or are looking to fix broken links and improve your SEO, there are several ways to implement them in WordPress. Which method is best for you will depend on your situation and skill level.
Sometimes the problem comes in redirecting WordPress, so this article is beneficial for that.
I’d better use a Plugin xd
Great article! it’s helped me to redirect my web page which I want to redirect.
Thanks for the nice post.
great article but I recommended use plugin for newbie
where can i get clomid prices: order generic clomid – where can i get clomid without prescription