PHP redirect (how to 302 & 301)

In the examples below the PHP code is saved to an index.php file at the domain root (http://www.lroguet.com) and redirects to the “blog” sub-domain (http://blog.lroguet.com)

Temporary redirect (302)

<?php
   header("Location: http://blog.lroguet.com");

Permanent redirect (301)

<?php
   header("Status: 301 Moved Permanently");
   header("Location: http://blog.lroguet.com");

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>