Redirect in WordPress

Redirect in WordPress

Sharing is caring!

Redirect is a way for your site to send a quick message to your viewer’s program and tell them that the page they want to visit has been moved, so their browser can automatically point them to the new page of your choice. This article is going to show you how to create a redirect from WordPress home page to any URL. 

WordPress Redirect 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:

Redirect 301 /oldpage.html http://www.yourwebsite.com/newpage.html

Folders can also be redirected in the same manner. You can also redirect a whole website with a 301 redirect using the following code:

Redirect 301 / http://www.yournewwebsite.com

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.

wordpress redirects

 

WordPress Redirect Using PHP

You can even redirect a page by adding a meta tag into your page header by utilizing the http-equiv attribute.

WordPress utilizes the PHP platform, therefore if you integrate any other scripts with WordPress, they will probably use PHP too. If 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:

<?php

header(“HTTP/1.1 301 Moved Permanently”);

header(“Location: http://www.yournewwebsite.com”);

?>

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.

WordPress Redirect Using Plugins

You can also redirect using Plugins.  There are a number of plugins that you can use to manage your redirects in WordPress.

 

Sharing is caring!

Comments are closed.