Tag Archives: http 301

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");