Return to Snippet

Revision: 18764
at October 7, 2009 20:22 by traeregan


Initial Code
if ((strpos($_SERVER['HTTP_HOST'],'www.')===false)) { header('Location: http://www.yourdomain.com'); exit(); }

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

Initial Description
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.

Initial Title
Force WWW Subdomain

Initial Tags

                                

Initial Language
PHP