Question

Tonight I installed a clean copy of WordPress on my local machine, with the intent of trying to set up a subdomain multisite installation. (I've got lots of experience using subdirectories, but this is my first time using subdomains.)

I set up the following hostnames in my /etc/hosts file:

127.0.0.1 multi
127.0.0.1 snoopy.multi
127.0.0.1 robots.multi

I installed WordPress and set up multisite as per the Codex's Create a Network page. I set up my Apache config so that snoopy.multi and robots.multi pointed to the same directory as multi. I signed in to http://multi/wp-admin/ and set up sites at snoopy.multi and robots.multi. Everything worked fine -- the new sites showed up in My Sites.

Only I couldn't log in to the subdomains' /wp-admin. If I entered the username and password that logged me in to the root site, I'd simply be redirected back to the login page. (Entering a bogus password did trigger the "can't log you in" message, though, which was weird.)

I did find a solution, and will post it as an answer here, in case anyone else runs into this issue. (That's kosher, right? I did a search to see if it had been answered before, but didn't find anything that sounded like exactly the same issue. If I'm wrong, please let me know.)

Edit

The solution below is apparently not a complete solution; I can log in to the subdomains' wp-admin pages, but now I'm unable to log in to the root site's wp-admin pages at http://multi/wp-admin . Any advice would be appreciated.

Was it helpful?

Solution

Google led me to this page: http://lauragentry.com/blog/2012/01/05/when-wordpress-network-subdomain-blogs-wont-let-you-log-in/

There's a chunk of code in there that I added to my wp-config.php file, to wit:

define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');

What I don't quite understand is why this works. Anyone know?

Updated It doesn't completely work -- I can now log in to the subdomains, but not the root domain.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top