SEO - 301 Cononical Redirect - Adds WWW


/ Published in: PHP
Save to your folder(s)

Issues a check to see if the "www" is included, if not, forces "www" to be appended to the URL in question.


Copy this code and paste it in your HTML
  1. <?php
  2. if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') {
  3. header('HTTP/1.1 301 Moved Permanently');
  4. header('Location: http://www.'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
  5. }
  6. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.