Posted By


traeregan on 10/07/09

Tagged


Statistics


Viewed 626 times
Favorited by 0 user(s)

Force WWW Subdomain


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

Sometimes you do not want users to access your domain without the www. If you want to force www.yourdomain.com and redirect yourdomain.com to www.yourdomain.com here is a simple way to do it.


Copy this code and paste it in your HTML
  1. if ((strpos($_SERVER['HTTP_HOST'],'www.')===false)) { header('Location: http://www.yourdomain.com'); exit(); }

URL: http://www.bradino.com/php/force-www-subdomain/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.