I am trying to force WWW. into my domain name, but by using PHP vs. HTACCESS like I have below. Is there any issues by doing it with PHP vs. HTACCESS? Does anyone have any code on how to set this up in the best possible manor?
#for all requests on mydomain.com
RewriteCond %{HTTP_HOST} mydomain\.ca$ [NC]
#if they are not for the www.mydomain.com
RewriteCond %{HTTP_HOST} !^www\.mydomain\.ca$ [NC]
#301 redirect to www.mydomain.com
RewriteRule (.*) http://www.mydomain.ca/$1 [R=301,L]