How to Redirect a Webpage using PHP
Here is a simple PHP script that will allow you to redirect a webpage visitor to another one quickly. It works on all browsers and if the user hits the ‘back’ button, they will be taken to the page they were redirected from.
PHP Redirect Script
<?php header('Location: http://www.yourdomain.com/newpage '); ?>
In order for the script to work it needs to be the only PHP script on the page. The URL above should also be changed the one you want to redirect to. (But you already knew that!)
Using htaccess for WordPress websites
If you are using a WordPress website you can use the server config file known as the htaccess file. It is a file for Apache web servers are you are most like using this type of server if you have a WordPress install. It can be found in you file manager.
Note: Sometimes, you need to select the ‘allow hidden files’ option when opening your file manager in order to view and edit the htaccess file.
The scripts below can be used to redirect specific pages or even your whole site and they are SEO friendly, meaning you won’t hurt your Google rankings when using them, the page authority will simply be redirected to the new page.
Simply paste this in your htaccess file and you should be good to go!
# This allows you to redirect index.html to a specific subfolder
Redirect 301 /index.html http://example.com/newdirectory/
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://domain.com/