I am logged in to my wordpress self hosted site at https://example.net it works fine but when I open https://www.example.net, it asks me to login again how do i fix?


Each subdomain requires separate authentication. Although you can leave your server set to allow both the "www.example.net" subdomain and the "root" domain "example.net", you'll run into issues both with authentication and with SEO, because Google also sees "www.example.net" as a different URL than "example.net".

It's best practice to decide which version you prefer, then set up your .htaccess file to redirect all requests of one to the other. That way you only have to log in once, and search engines as well as visitors will all get the same version of your URLs.

If you prefer www:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

If you prefer no subdomain:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Place whichever one you prefer above the default WordPress block in your site root's .htaccess file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.