For a website or web application user to access the website with or without "www" (e.g. domain.com or www.domain.com) for same page. It will be consider as "content duplicate". Due to this website rank to be drop. The following code to redirect the non-www to www.