PHP Permanently Move A Page

The proper way to move a page and have search engines properly find it is to use a 301 redirect. The 301 redirect tells the search engines that “this page has permanently moved”. I am in the process of redirecting an entire website using 301 redirects, and I will post updates on the impact this has on the SEO and search engine placement on the site. The code to do a 301 redirect in php is as follows:

<?php

// Permanent redirection

header("HTTP/1.1 301 Moved Permanently");

header("Location: http://www.somacon.com/");

exit();
?>

Be sure you put the line : header(“HTTP/1.1 301 Moved Permanently”); Because as I have recently discovered, just using the header location line does a 302 redirect instead of a 301.  A 302 redirect tells the search engines that “this page has temporarily moved”.  So be sure you do this correctly if the page is permanently moving.

You Might Also Like...

  • admin
    The A record is fine, The 301 redirect would be used if you bought or had a similar existing site with different but similar content. Eliminating the site but passing all of its link juice to the main site.

    Our main website is .com, but then we have .biz, .org, .net, etc, and the A records on the Domain server all point to the same server IP, and then I just put in the various headers in IIS for that site. So you are doing the right thing for your situation in my opinion.
  • Dave
    Hi I have a question I have two domain names a .tv and a .com I have them hosted on a shared server I am doing this so I can get emails. I have set up a A record that points to my web server is this the right way or should I trash the A record and put in 301 ? Thanks in advance for any help.
blog comments powered by Disqus