I have search through Google and found 2 methods to add www before domain name. First is by adding a CNAME and second is using rewrite mod in .htaccess file.I just want to know which method is better to use or there is other method because I'm currently using standalone WordPress as my back end.
Which method is better to add www. before domain name
htaccess;url;url rewriting;cname
You need both - the CNAME is a DNS record that points www.example.com to example.com's server so that if a browser tries to open www.example.com then it can find what server (IP address) it is stored on. The second is a rule on the server that says if someone loads example.com, tell them that they should have loaded www.example.com