Background
It’s sometimes necessary to redirect all URLs pointing from one location to another. This is especially true if you want to keep your Google rankings for SEO purposes. The bottom line is Google doesn’t like it if you move pages without specifying a 301 or 302 redirect. If you don’t specify the redirect, Google could take months to update it’s index with all your changes and it will definitely affect your search rankings.
If you’re using Apache it’s very easy to do a redirect. Simply create a .htaccess
file in the root of your web directory and specify the information below.
Redirect 301 /knowledgebase/wordpress/ /knowledgebase/wordpress-hosting/
The above example will make everything under the wordpress
directory and redirect it to the wordpress-hosting
directory.
If the file already exists, the just append it at the end, or any other logical place that will work for you. I personally like adding it like so:
# BEGIN Vander Host Redirect 301 /knowledgebase/wordpress/ /knowledgebase/wordpress-hosting/ Redirect 301 /contact/ https://my.vander.host/contact.php # END Vander Host
The reason why I put the # BEGIN
and # END
blocks is because then when I’m looking for customisation in the .htaccess
file they are very easy to find.
Conclusion
.htaccess
redirects can take numerous formats but the above example should take you a long way in solving everyday redirect issues. If you would like more information on redirects, or find out more about Vander Host’s exceptional WordPress hosting solutions, leave a comment below or be sure to contact us.
NGINX Redirection
If you want to do redirection but you have an NGINX web server instead of an Apache web server, follow this link: