SEO - 301 Cononical Redirect - Removes WWW


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

Removes WWW from the current URL, if exists.


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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.