Like Us on Facebook

How to redirect non-www URLs to www without htaccess

To redirect your yourdomain.com to www.yourdomain.com you have to write a simple code using php. Bellow code you have to paste at the top of your page.
 
<?php

        $protocol = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://";
    
          if (substr($_SERVER['HTTP_HOST'], 0, 4) !== 'www.')
           {
               header('Location: '.$protocol.'www.'.$_SERVER['HTTP_HOST'].''.$_SERVER['REQUEST_URI']);
               exit;
            }

?>
 
And now when someone go to your domain like yourdomain.com he will be redirected to www.yourdomain.com.

Posted By UandBlog

UandBlog is a Global Leading source of Finance, Health, Lifestyle, Technology, Gaming and Programing and other information, it is a fastest growing blog for all , for latest post or information like us on facebook , follow on Twitter, Google+ and Pinterest.

Comments ( 0 )

    Leave a comment..

    Click to login.