Add or Remove WWW in WordPress

www is technically a sub-domain – but it usually shares the same /httpdocs/ or /public_html/ or /www/ folder on hosts as non-www, it also is configurable in many different places and varies from host-to-host, so it gets confusing at times.

As such, this question comes up daily on the WordPress Support Forums and being that I’m tired of writing personalized responses to them – here’s a quick and easy break down:

Site Address and WordPress Address

When you’re in Dashboard > Settings > General ensure you’re changing both the “WordPress Address (URL)” and “Site Address (URL)” to include or exclude your www.

If you’ve locked yourself out of /wp-admin/ because of a www change and are seeing a white screen or experiencing a redirect loop: head to your database via phpMyAdmin, look for *_options and change the siteurl and home values to have or remove www.

If you have a WordPress Network / Multisite setup – there’s a few more steps for this:

  • in wp-config.php make sure the DOMAINCURRENTSITE is set to your www preference

in blogs and *site make sure everything’s set to your www preference
in all *options make sure home and site_url are also at your www preference

Check Your Web Host (control panel, plesk)

Changing www in WordPress isn’t always enough, sometimes your server needs adjustments. Any of the above hosting managers (often in the “domains” section) will have a question about your domain if you “want www prefix” to prepend to your domain. Select what you’d like!

You can see if www is enabled on your current domain’s server/host/setup by going to your WordPress’s readme.html file (which is an independent file that doesn’t have anything to do with PHP, database, or your entered url’s) Simply visit via your WordPress install location (example: http://WWW.yoursite.com/WordPress/readme.html)

Force www Preference with .htaccess

If it’s just being a pain, or perhaps your site is running www or non-www fine but the opposite is still rendering, make a redirect with .htaccess to immediately redirect users permanently (Search engines will respect this as they’re 301‘s)

The three areas above, used independently or together (depending on your setup and host) should resolve your www headache.


Leave a Reply

%d bloggers like this: