Redirect wordpress site to www from non www on wordpress server

Unfortunately on wordpress.com hosted sites, the www is automatically removed.

For self-hosted wordpress installs, there are several ways to do this.

In .htaccess file using something like:

Options +FollowSymlinks
RewriteCond %{HTTP_HOST} !^(www\.|$) [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

or set values for WordPress address and Site address in the WordPress Admin Dashboard:

Settings > General

or define in your wp-config.php file:

define('WP_HOME',"http://www.example.com");
define('WP_SITEURL',"http://www.example.com");

or in your theme functions.php file or a plugin.

I think your issue might be one of the above is conflicting with your changes which then causes a redirect loop.