Resolving The WordPress Multisite Redirect Loop

Though I do the majority of my work using single site WordPress installs, there are a number of sites and projects in which I’ve used WordPress multisite and there’s a problem that I’ve experienced specifically with using WordPress multisite, subdomains, and shared hosting environments.

Specifically, the problem is this:

  • Install WordPress and activate multisite
  • Configure the installation to use subdomains (versus subdirectories)
  • Attempt to login and get stuck in a redirect loop

If you have a single instance of WordPress multisite installed on the same server, there’s no issue, but if you go beyond that then you normally hit a problem: a redirect loop.

The WordPress Multisite Redirect Loop

The WordPress Login Screen

The most frustrating screen ever (in a redirect loop, that is).

Once you’ve increased the number of your multisite installs beyond one, then you’re likely to be unable to login as you’ll get stuck in a redirect loop. That is, every time you try to login, you’re returned to the login screen.

Luckily, the fix is relatively easy.

In your wp-config.php file, add the following lines of code:

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

And do so just before the line that reads:

/* That's all, stop editing! Happy blogging. */

Once done, the redirect issue should be resolved.

Why Does This Happen?

Whenever you’re running multiple versions of WordPress on the same server, you can visualize the setup like this:

WordPress Multisite Installation

WordPress Multisite Installation

Basically, each version of WordPress, regardless of its domain or subdomain, maps to a single IP address. In this case,

When a request comes into the server, part of the request includes the domain. A domain is associated with an IP address. When a cookie is created, it includes the name, some sensitive content, and then the path.

For example:

NAME = wordpress_d676ec21cf050e966685794aa715694f
CONTENT = removed
PATH = /sitename/wp-admin

In a WordPress Multisite setup a cookie for two sites may look like this:

NAME = wordpress_d676ec21cf050e966685794aa715694f
PATH = /sitename/wp-admin

NAME = wordpress_d676ec21cf050e966685794aa715694f
PATH = /sitename/

Notice that the name of the two cookies above are exactly the same but the path’s are different. This is because two different sites with different domains are hosted on the same IP address, and they both exist in the cookie because the cookies aren’t being reset.

Cookies Being Set By WordPress

Cookies being set for the different sites on the same domain.

As such, when you attempt to login to a WordPress installation on a different domain (but on the same IP), the cookie is essentially invalid.

Thus, WordPress – in the most technical term possible – wigs out.

But more seriously, wp-login doesn’t attempt to look for cookies before actually setting them. This means that an invalid cookie is being used and since it doesn’t attempt to clear the existing cookies, you get stuck in the login loop.

Thus, the big picture looks something like this:

WordPress Multisite and Cookies

WordPress Multisite and Cookies

Sure, clearing the cookies will do the trick, but users shouldn’t have to do that. Additionally, not everyone will see this problem occur, but if you’re in the business of managing a multisite installation in a shared environment, then you’re likely to see it.

The code above will ensure that WordPress is clearing the cookie for the given domain of the multisite thus allowing the login process to set it correctly.


This snippet of code worked like a dream, so thank you. Odd that I had the problem a day after you posted the solution too.

Thanks so much for posting this, I’m anxious to try it on an issue I’ve been having after a Multisite migration attempt. I’ve migrated a Multisite install to another domain for dev-ing and am getting this redirect.

Hopefully this will solve the issue for me:)

    Sure thing – if it doesn’t work, let me know. This particular issue is one that obviously hits close to home so being able to provide as many solutions to it as possible would be great.

      I tried to solve this issue with the solution you provided but it still doesnt work. Any other thing to try ?

      Thanks in advance.


      Hi Tom,
      I am having this issue with the new install of WP 3.6.
      I installed fresh, activated multi-site, and created a new site. I am woring with sub-folders. Now it is giving me the redirect error:

      The page isn’t redirecting properly

      Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

      This problem can sometimes be caused by disabling or refusing to accept

      I tried using the code you suggested and it isn’t working. I’m thinking it’s because you were working with sub-domains instead of the sub-folders.
      Do you have any suggestions? It has been awhile since you posted on this, so I thought you may have figured something out.
      Thank You!

        Unfortunately, I’ve got nothing in addition to the content mentioned here as this is what’s ended up solving my issue.

        If you end up solving it on your end, feel free to leave it in the comment stream here just in case it may help others :).

Worked like a charm! I was banging my head against my keyboard trying to figure out what was making it loop. And, oddly, I just installed with just one site.

I had similar problem with a sub-directory WPMS setup. mine would come up with a browser error of too many redirects. I had already tried clearing cookies and cache.

This fix solved it! Thank you!

I also had a cookie problem on a subdirectory install of multisite. One point to mention and i’m not sure why this occurred but WP didn’t like this line:

define(‘COOKIE_DOMAIN’, ”);

Once i removed that line from wp-config.php it seemed to still fix the problem.

Any thoughts?

THANKS A LOT you solved my 1hr-headache.
Peace and love to you and your family.

I also have a loop in wp-admin section. I’ve added your code, but it still have no effect: the login redirect loop is here.

Thanks that really helped! I don’t really follow why this is a problem on local and not on a live server, which will also have the same IP for each site?

Secondly, as I’d like to maintain one set of code that works on live and local, can the 4 paths exist in the LIVE config file, or will this break logins there?

    Thanks that really helped! I don’t really follow why this is a problem on local and not on a live server, which will also have the same IP for each site?

    That is odd as I normally see it the other way around :). I was going to double-check about the IP issue on the server, but if it’s not a problem there then it may simply be a result of the routing mechanism setup on the server (unless you’re on a run-of-the-mill host).

    Secondly, as I’d like to maintain one set of code that works on live and local, can the 4 paths exist in the LIVE config file, or will this break logins there?

    The most critical paths are in the database, so if you have different paths for your siteurl and home values in the wp_options table, then you’re out of luck. =T

Greetngs Tom, and thanks for all the information which has been provided above.

We have applied the changes above, but it has yet not resolved our error. For we have a setup such that and The login for works correctly, but the login for gives an error.

We have tested, the configuration for both the blogs from the admin console, we have tested all the php files which are the same except for a few obvious changes.

Any inputs or pointers will be appreciated.

    Hey Saurab,

    Unfortunately, there may not be much more can I offer. What error does the login for give? Make sure that that user has been granted permission in the main multisite admin panel – sometimes that can cause an error.

      Hi, I should have stated it more correclty. My mistake. The login on does not give an error but redirects to the /wp-login.php without any error as such. No message on the screen. Just verified that the user has been added to and has adequate permissions.

      One more funny thing which I observed, is if i go to the main blog and navigate to my list of blogs, and click on the blog, it opens the blog for me. Then I type /wp-admin at the end as in and press enter. I am taken to the dashboard.

      Thanks and appreciate any help you can give me. Frankly can use any help I get.

        Unfortunately, this sounds like more complicated of a problem that I can provide via blog comments, but I’d double-check your .htaccess file, your wp-config.php file, clear your cookies, and disable any caching plugins if you have them.

        I’d also recommend trying to login with another browser and see if the problem persists there, too. If it does, then the problem definitely exists on the server so that’s the next place I’d start looking.

Thanks so much. I’ve spent days looking for this problem. You fixed it

A BIG thank you to you!!! forums have 2-3 years old discussions about this with no real solution. I had to google this and visit an external site, wow!

Thank you for documenting the solution to a very difficult problem. It worked for me, twice!

Your solution worked until I installed the domain mapping plugin “wordpress-mu-domain-mapping”. It required me to comment out the second line:
define('COOKIE_DOMAIN', '');

I didn’t know it at the time because I was still logged in but that inevitably broke my setup because after a reboot, I could not login. The redirect loop was back! My sites were all rendering when visited by the subdomain url but I could not login to any of them.

I came back to your post and tried to remove the comment the COOKIE_DOMAIN line and then everything broke. The solution I came up with was to remove the network activation of the “wordpress-mu-domain-mapping” plugin using phpMyAdmin. Once the plugin was removed, sunrise.php removed from wp-config.php and the COOKIE_DOMAIN line back in action, I was in business. It worked.

My head is spinning after editing…

wp-config.php in WordPress
hosts file on Windows 7
httpd.conf in the WAMP Apache config
httpd-vhosts.conf in the WAMP Apache config
and .htacess in the virtual host setup…

it’s quite complicated.

Thanks again for your continued dedication to the WordPress community.

    Thanks so much for sharing what you ultimately had to do to get it to work – each environment can be tricky and this helps to provide a good solution for others who stumble across the same problem :).

    I had the same problem. It existed prior to installing the MU Domain Mapping Plugin.

    Adding these did fix the problem.

    1 define(‘ADMIN_COOKIE_PATH’, ‘/’);
    2 define(‘COOKIE_DOMAIN’, ”);
    3 define(‘COOKIEPATH’, ”);
    4 define(‘SITECOOKIEPATH’, ”);

    but the 2nd line “define(‘COOKIE_DOMAIN’, ”);” is incompatible with the MU domain mapping plugin. It makes you take out the line, and soon as I do, the login loop problem comes back. What does this mean? Is the plugin basically crippled at this point?

    My setup is:
    a clean fresh install of WordPress 3.5.2 and
    Version of MU Domain Mapping.

      Unfortunately, I can’t offer much advice here as I don’t use the domain mapping plugin – I’ve just made those modifications to my `wp-config.php` (in a multisite install) and it was all I needed.

      Wish I could be more help.

        Yeah setting COOKIE_PATH to empty string can cause issues with plugins that use cookies.
        I had issues with the Easy digital downloads cart after doing this.
        setting it to forward slash solved it though

This was a very helpful post. I found that once I included this in wp-config.php, I could finally log into wp-admin. Once I got in, though, it was forcing me to log in again to each site when switching from dashboard to dashboard. So once I had logged into each dashboard, I found that I could remove these constants and everything started working normally.

Hi there,

i recently asked my developer to transfer all 7 of my wordpress websites into one multisite.

The main site is which is like a ‘quick view’ portfolio site.

I then have different sites for different products linking from this site for example

My developer has set up the domain as that seem to redirect to

I’m not sure, but I believe that Google does not like re-directs for SEO etc so I was wondering if it it possible to set up multisite without using

Any feedback or advice would be greatly appreciated.

Many thanks,

Tommy (:

I implemented the code but I still have the redirect problem. The domain in question is not the main domain of my hosting account. I mean, I purchased the hosting service with “”. Several months after, I setup the “” as an add on domain via cpanel. This is the domain that is causing me the redirect loop when I create the new multisite “site” with the address “”

Do you think that being “” an add on domain in my main account is causing this solution not to work?

I set up an NGINX+Wordpress+W3 thingy on AWS free tier and then activated multisite (sub directories, no sub domains). Then while trying to access the newly created site’s dashboard, got stuck in the redirect loop. Also the new site looks horrible. Implemented your fix. Didn’t work. Configured the NGINX config file to chew out the www part and used rewrite ^(.*)$1 permanent; to sort out any non-www vs www problems for multisite. Also in wp-config, just left the define(‘MULTISITE’, ‘true’); part and commented out the extra load given by WP while setting up multisite to avoid confusion with www and non-www. All these failed. Need help :(

    Hey mk,

    Unfortunately, there’s not much more support than I can offer than what’s included in the post above.

    If I were in your position, I’d start back from ground zero and completely turn off multisite, clear your cookies, and follow each step one-by-one.

    Other than that, that’s the best I can do =T.

Oh my it works, really great snippet, Thanks alot!!

Thanks so much! I spend hours on trying to solve this and read about a dozen other forums threads trying to find a solution, but nothing worked. Your solution finally does.

Just one thing I want to add. I also tried clearing the cookies, cache, using a different browser etc., but I was still getting the loop. So I’m happy that is does work, but your explanation why doesn’t make sense to me in this case.

Thanks again!

thanks for this Tom, it helped! Even though I don’t really get the explanation :)

This problem plagued me for hours. I’m so glad I stumbled on this page. The code worked like a charm!

Thank you, thank you, thank you! Oh, it feels so good to finally be able to log into my site again! Bless you for supplying this code.

Thanks for this. Resolved our issues with MU WordPress 3.6 running on Ubuntu12.

Hi ! i have some time dealing with this problem, and i can’t fix it yet, i try your solution, but it’s not work for me, do you have another advice, or some point that i’ve missed ?

thanks for share !

I was also having this issue and I couldnt fix it with the solution displayed here. Anyway, I checked the php log file and I saw it was a problem with two specific tables not being created in the wordpress install: wp_blogs and wp_sitemeta. It seems like wordpress MultiSite checks these two tables on loading.

This may seem far from being the real solution to this problem but it was my specific case. Thanks.-

Hey tom, i am facing same problem, but the solution provided didnt worked for me. May be one of the reason could be that i forgot to add blog.dir folder in my wp-content at the time of enabling multi site

Hi there,

I have similar problem with my WP multisite install under Nginx box.

every I visited my domain, it always redirected to the signup page with link look likes

I have tried your solution by modifiying wp-config.php, but it returned this message, every I visit my domian

The constant “COOKIE_DOMAIN” is defined (probably in wp-config.php). Please remove or comment out that define() line.

I’d appreciate anyone who can help me resolve this issue

Thanks for this, Tom! The wp-config.php code did not help my problem (though, I’m glad I know about it now) but clearing my cookies did. Just thought I’d put that into the conversation.

Adding to reports that these steps broke my WPMU setup… resulted in a white screen with:

“The constant “COOKIE_DOMAIN” is defined (probably in wp-config.php). Please remove or comment out that define() line.”

Removing that line, so it just says
define(‘ADMIN_COOKIE_PATH’, ‘/’);
define(‘COOKIEPATH’, ”);
define(‘SITECOOKIEPATH’, ”);

works great.

Thanks so much Tom

Sorry Tom, cancel that last comment – redirect loop still there on some sites. it seems the line that clashes cannot just be removed.

Tom! Please excuse my previous emails. But I believe I have a solution.

Domain mapping is case sensitive. So will work, but will have a redirect loop.

I hope this helps someone, and thanks for your work on this issue.

Thank you so much. really feeling relax now. Thanks again.

Tom, thanks so much. Great fix. One thing to note. With WordPress 3.8 this issue doesn’t occur with subdomains ( and because wordpress sets the cookie-domain to “” enabling single signon between the two. But it sure as heck does happen when you have 2 sites in a mult-site wordpress installation like and

Thanks again

    Thanks so much for noting that it’s not an issue with WordPress 3.8 – well, at least not in some cases ;) – this will be good for anyone else who stumbles across this post.

LOL, I actually found your article exactly before I encountered that bug. Thanks so much for the solution!

Thanks for this Tom. It worked perfectly! =)

Tom ? You saved my life ! hahahahahaha :D

Legend! Had this problem for just 2 days but has been driving me insane, such a simple fix – thank you!

Thanks for posting this but sorry to say it didn’t work for me.

What did work was replacing the rewrite code foor the .htaccess that was generated during the network set up with the code given in the wordpress codex site found at the following link:

This worked immediately :)

    Thanks for posting your solution – it’s great to have for reference for others who experience the same issue.

    Ditto. I used the “Fubfolder Example WordPress 3.0 through 3.4.2″ htacess template on my 3.9.1 install (has been upgraded through versions and not sure what about that means you have to use different htaccess rules)…

    … but anyway those htaccess rules fixed a similar redirect loop issue for me on a subfolder multisite setup.

      Thank you Jason!

      Your post helped me resolve the same issue today because it was not clear (to me) what version of the .htaccess file I should use. I knew I was working with an older WordPress install, but I was not certain how old.
      Now running the current WordPress Version 3.9.1 and I recently converted it to multisite with subfolders and got stuck in the “too many redirects” loop with the first sub-site I installed. It required the .htaccess file for “WordPress 3.0 through 3.4.2″ and that did the trick.

      Thanks to Tom for originating this useful topic. The discussion is still helpful over a 18 months later. -Cheers

        Glad to have been able to have offered help, Michael! And glad to have others commenting on this issue and contributing their fixes :).

Thanks! I was setting up multisite for a Magento integration, and was near pulling my hair out as I had everything set up correct, but kept getting this login redirect loop. The code worked like a charm even with no modifications necessary. Running multisite in a subfolder install under magento, so that’s two htaccess files to consider. Thanks again!

works great, thanks a lot

Ran into this today with a client site. He installed a security plugin which added:
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);

to his WP-CONFIG.PHP file caused a loop since he didn’t have a cert installed for his domain.

Also, on my own multisite install I had a loop issue until I fixed the permissions/ownership on .htaccess as I created it when logged in as ROOT and forgot to fix it when I was done.

I LOVE YOU!!! Thank you thank you thank you!!!

Brilliant. Thank you so much! Those 4 lines of code solved my problem. (And thanks for defining very clearly why it happens too. That was interesting to learn.

Thank you SO much!! I just saw this error on my blog and freaked out, and this fixed it in about 30 seconds.

has anyone ever told you that you are awesome.

Cheers Tom, if only i found this blog over 2 hours ago and 3 re-installs earlier.

My programmer is trying to convince me to move to .net from PHP.
I have always disliked the idea because of the costs. But he’s tryiong none
the less. I’ve been using Movable-type on numerous websites for about a year and
am worried about switching to another platform.
I have heard fantastic things about Is there a way I
can import all my wordpress posts into it? Any kind of help would be really appreciated!

    My programmer is trying to convince me to move to .net from PHP. I have always disliked the idea because of the costs. But he’s tryiong none the less.

    When you’re talking about the costs, are you talking about the costs that you’d incur moving something from one architecture to another (that is, paying someone to port an application)?

    I mean, the licensing for .NET for commercial products is pretty expensive itself so there’s one argument against it; however, I used to do .NET, too and was happy with the environment so I’m playing devil’s advocate more than anything else.

    Is there a way I can import all my wordpress posts into it? Any kind of help would be really appreciated!

    Unfortunately, I don’t know about moving from WordPress to another system as I’m 100% focused on WordPress these days.

Thanks that solved my problem!

Thanks man, this worked like magic for my website. Keep up the good work :)

Also ran into this issue, added in the supplied code but the redirect loop kept occurring. Managed to get it fixed in the end though!

I read elsewhere that ‘localhost:80′ wont work WP multi-site, so I tossed a domain in my hosts file (let’s say to point to

After that, I went through all of the WP database tables, replaced any “localhost:80″ occurrences I found with “”. Then update define(‘DOMAIN_CURRENT_SITE’, ‘′) in wp-config.php, restart my webserver… and voila.

The above probably only applies to rookies like me that were dealing with localhost and just kind of derping along.

Solution for my problem with WPMU Domain Mapping without using the COOKIE_DOMAIN fix in the UK at least.

Watch out for incompatible domain names basically… Try a traditional format one. e.g instead of

Some browsers (Google) appear to be rejecting new style domains it seems confusing them with TLD’s I think.


Thank you, Thank you, Thank you! I have been playing with this for a week. I gave up, went back to single site and decided to give it one more go. I wouldn’t have been able to have a multi site network without your expertise so I sincerely thank you.

Gracias por esta informacion!

Solved!! Thx for this greating post!

But you can make an informed decision which makes all
difference. However, there are many ways of getting a sun tan,
and the Sun Laboratories Self Tanner Buy enables you to explore one of them.
The finest self-tanning product manufacturers have a range of tanning creams, lotions, and sprays that you could try to see which
suit you best.

Thanks! Your solution worked perfectly.

Hello !

I’m using Networks for WordPress plugin so I have many networks.
Despite they all using the same database and user credential. When a user login from network1 and visit another Network2 he need to login again..

I’m looking for days to find a solution to fix that so user can have a one global login.
I started to look for cookies solutions and I found your blog.. You think your solution will work consider the information i just gave ?

Thanks a lot !


Found a solution !!!
adding this the my config.php
// Cookies
define( ‘COOKIEHASH’, md5( ‘’ ) );
define( ‘COOKIE_DOMAIN’, ‘’ );
define( ‘ADMIN_COOKIE_PATH’, ‘/’ );
define( ‘COOKIEPATH’, ‘/’ );
define( ‘SITECOOKIEPATH’, ‘/’ );
define( ‘TEST_COOKIE’, ‘thing_test_cookie’ );
define( ‘AUTH_COOKIE’, ‘thing_’ . COOKIEHASH );
define( ‘USER_COOKIE’, ‘thing_user_’ . COOKIEHASH );
define( ‘PASS_COOKIE’, ‘thing_pass_’ . COOKIEHASH );
define( ‘SECURE_AUTH_COOKIE’, ‘thing_sec_’ . COOKIEHASH );
define( ‘LOGGED_IN_COOKIE’, ‘thing_logged_in’ . COOKIEHASH );

This was a life saver.

A couple of things to note though.
1.) Definitely need to remove the define(‘COOKIEDOMAIN’, ”); line seems to interfere with the Domain Mapping plugin, like others have mentioned.

2.) If you’re still receiving the infinite loop on any domain mapped with Domain Mapping plugin, you need to clear your cookies in the browser. Once I cleared my cookies the looping went away.

Thanks again, this saved a lot of headache and time trying to get this up and working.


I got the following error: “The constant “COOKIE_DOMAIN” is defined (probably in wp-config.php). Please remove or comment out that define() line.”

Commented that line out and everything was okay.

You’re a star!

Any chance of getting you interested in looking into this problem again?

My multisite wordpress install works for years without problems. But since some WP update (can’t recall which one, but it was several months ago) I seem to be getting the login redirect problem on ONE PARTICULAR SITE ONLY. I can login to the main site, I can login to any subsite, except to one particular one. I have been able to avoid the problem, but the customer is requiring a change now and I can’t help him.

I am not very good with my linux and apache know-how, I only know my way around html and css and php, basically.

FYI: Well, I don’t really know what the real cause was, but when I deleted my browser’s cookies, then the problem was gone.

Worked fine!!!!!!!!!!!!!

I solve inserting this in .htaccess:

BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ – [L]

uploaded files

RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

add a trailing slash to /wp-admin

RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ – [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]

END WordPress

Thanks man! Solve my problem ;)

I have the same problem, however its only happening when we try to login into the admin portion externally. I added the 4 lines of code to my config.php file and the issue is still there. Any suggestions?

You just saved me tons of frustration. This worked great–thank you!

Having the COOKIE_PATH set to empty will cause the shopping cart for WooCommerce to empty upon adding of products to the cart. Adding a “/” to COOKIE_PATH instead of having it empty works like a charm. Hope this helps anyone with WooCommerce empty shopping cart issues.

    5 letters : M E R C I

    I wish Tom could append your tip as a comment in the post’s body to improve relevance in search results : Solving these two issues at same time is really hard to figure.

    Thanks again for your precious comment.

Greetings Tom, great article. I have a Similiar Issue with a Redirect Loop on a SSL Domain. I’ve spent hours trying to locate issue. Changed Permalinks, checked htaccess file for redirect and nothing. Standard http works ok. Will adding your code also work for Non-Multi-sites? Thanks in Advance.

    It should work for non-multisites, but depending on the nature of the configuration on the server, I can’t promise that this will solve it.

Leave a Reply

Name and email address are required. Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>