How To Redirect URls With WordPress
If you later decide to change your permalink structure, or if you remove posts or pages, you will generate 404 page errors. A 404 page error should be displayed to visitors when a page has been removed, however if the content has simply been moved to a different location on your website, you should redirect the visitor to the new location.
To see if your website has any 404 page errors, log into Google Webmaster Tools then go to the crawl section. In the Crawl Errors page, Google highlights any page of yours that Google is unable to index.
Google Webmaster Tools will advise you of any 404 page errors on your website.
There are other reasons why you would want to redirect a page, however for 99% of website owners, redirection is necessary when they change their URL structure or alter the post slug of an article.
In this article, I would like to show you how you can redirect a URL on a WordPress website.
What is a 301 Redirect?
The majority of redirects use what is known as a 301 redirect. This is named after the HTTP response status code 301, which informs search engines that a page has moved permanently.
Search engines advise website owners to use a 301 redirect whenever a page has permanently moved. 301 redirects ensure that page rank, and any other “juice” that a search engine gives a page, is transferred to its new URL.
There are other redirects available such as 307 (temporary) and 308 (permanent); however you should use 301 redirects whenever a page URL has changed so that search engine rankings and traffic are not affected.
How to Redirect a Page Using Htaccess
You can create 301 redirects using the .htaccess file if you are using an apache server. All you have to do is specify the old location and the new location. You can do this with the following code:
Folders can also be redirected in the same manner. You can also redirect a whole website with a 301 redirect using the following code:
All you need to do to check if your redirection is working is load the page you are redirecting. If its working correctly, you will be redirected to the new page.
How to Redirect a Page Using PHP
It is possible to apply redirects using many different languages including ASP, ColdFusion, Perl, and Java. You can even redirect a page by adding a meta tag into your page header by utilizing the http-equiv attribute.
WordPress uses the PHP platform, therefore if you integrate any other scripts with WordPress, they will probably use PHP too. If you find yourself in a situation where you need to redirect a PHP web page that is outside your WordPress installation, you can use a PHP redirect.
You can redirect a PHP page by adding this line of code to the header:
header(“HTTP/1.1 301 Moved Permanently”);
Note that the “301 Moved Permanently” line is necessary to advise search engines that you are using a 301 redirection. You also need to ensure that this code is placed at the top of the page to ensure the redirection works correctly.
If you would like to use redirection within a theme or plugin you are developing, you can use the WordPress wp_redirect function. The function will redirect links using a 302 redirect by default; however this can be changed by modifying the $status parameter.
How to Redirect a Page Using a WordPress Plugin
The beauty of WordPress is that you do not have to have a technical background in order to maintain your website. While you can use .htaccess or PHP to redirect pages, it is simpler to use one of many great redirect plugins available for WordPress.
One such solution is Quick Page/Post Redirect Plugin. The plugin allows you to perform 301, 302, 307, or meta refresh redirects.
Redirects can also have nofollow tags attached to them and be opened in new windows. All you have to do is check a box to enable this functionality.
Quick Page/Post Redirect Plugin is a practical redirect solution that is easy to use.
Redirection is a great plugin that features 404 page monitoring. It will show you exactly what pages are generating 404 page errors and allow you to create 301, 302, and 307 redirects, for each of those links.
It allows you to redirect URLs to random blog posts or directly to your 404 error page. Redirections can also be allocated into groups to help you can manage all of your redirection links correctly.
Redirection helps you find 404 page errors and allows you to redirect links to many other URLs and random posts.
Another solution is SEO Redirection Plugin. The plugin supports 301, 302, and 307 redirection. It also supports wildcard redirection and can automatically redirect any 404 errors it finds to a specific page.
SEO Redirection Plugin is one of the few plugins that supports wildcards.