Advertisement
yesamarcos

Force non-www and https

Jun 13th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.26 KB | None | 0 0
  1. $url        = "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
  2. $novaurl    = str_replace("www.", "", $url);
  3.  
  4. if (substr($_SERVER['HTTP_HOST'], 0, 4) === 'www.') {
  5.     header('HTTP/1.1 301 Moved Permanently');
  6.     header("Location: https://{$novaurl}");
  7.     exit;
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement