WordPress Login via www and non-www

Solution:

You can only have one or the other.

  1. Under ‘General Settings’ in your WP control panel, specify your address in your preferred way, ie. with or without ‘www’.
  2. Assuming you are on a server running apache: create one of the following .htaccess files in the root of your site.

 

# Redirect www urls to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC]
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]

 

# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]