How To 301 Redirect With PHP
Search engines index pages by the URL of the page, if these pages are moved to a different URL then the search engines will have indexed a page that no longer exists. Therefore people search in the search engine and find your people, click through to your website and they will get a 404 message. This is not only a bad user experience but also bad SEO, search engines do not want to index 404 pages.
If you move an index page to a different URL you need to make sure you do a 301 redirect to the correct page. A 301 redirect will tell the search engines that this page has been permanently moved to a new location and to change the index to the new URL.
You can easily do this in PHP by changing the HTTP header.
Copy the following snippet to the top of the moved page to 301 it to the new location.
<?php Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://newurlhere.com" ); exit; ?>
Subscribe To Newsletter
Get weekly updates to your email