can't login on mapped domains when w3tc page cache enabled

My domain mapping is setup like this:
Admin Mapping: original domain
Login Mapping: original domain
Cross-domain: no (i've tried yes)

Everything works fine until I enabled w3tc page cache.

If I go to http://mappeddomain.com/wp-admin I get forwarded to:

UNMAPPEDDOMAIN/ORIGINALSLUG/wp-login.php?redirect_to=MAPPEDDOMAIN%2Fwp-admin%2F&reauth=1

That fails to login, and then I get sent to: UNMAPPEDDOMAIN/ORIGINALSLUG/wp-login.php?redirect_to=MAPPEDDOMAIN/ORIGINALSLUG%2Fwp-admin%2F&reauth=1

I don't know for sure, but I believe the issue is that for some reason on these mapped domains there is a re-write rule such that I'm getting mappeddomain/originalslug/wp-admin Which obviously doesn't exist.

I'm assuming that it's an issue with the W3TC re-write rules and the domain mapping plugin. The re-write rules created automatically in htaccess are as follows:

# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.*\/)?w3tc_rewrite_test([0-9]+)/?$ $1?w3tc_rewrite_test=1 [L]
    RewriteCond %{HTTPS} =on
    RewriteRule .* - [E=W3TC_SSL:_ssl]
    RewriteCond %{SERVER_PORT} =443
    RewriteRule .* - [E=W3TC_SSL:_ssl]
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
    RewriteRule .* - [E=W3TC_PREVIEW:_preview]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond %{HTTP_USER_AGENT} !(W3\ Total\ Cache|iphone|android|ipad) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html" -f
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html" [L]
</IfModule>
  • Dan Berdal
    • Design Lord, Child of Thor

    I thought I would follow up with the following info, since you might ask.
    If I enabled cross domain login I can login to my root site, but I try to access the dashboard of mapped site I get an infinite loop

    If I change
    Administration Mapping: Mapped Domain
    Login Mapping: Mapped Domain

    Then the the user can login correctly on mapped domain.

    However, I want to use original domain so I can have https for logins on all sites.

  • Ken Kimbrell
    • The Crimson Coder

    Hello Dan-

    Yes, you will need to enable "Cross-domain autologin". Which you have done, however usually one other problem aside from that is you will need to go into your root folder where your core wordpress installation resides. Find your wp-config.php file. Then see if W3TC added this configuration code:

    define('COOKIE_DOMAIN', 'your-domain.com'); // Added by W3 Total Cache

    If so, remove it completely then try again please.

    Take Care,

    Ken - WPMU DEV Support

  • Dan Berdal
    • Design Lord, Child of Thor

    This is a caused by a messy combination
    of domain mapping set to:

    Admin mapping: original domain
    Login mapping: original domain
    Cross-domain login: enabled
    enabling SSL for the "original domain".
    and page caching

    The solution for me is:

    disabling cross domain login (non secure cross domain scripts are getting blocked , and it's just not working anymore)
    Under W3TC page cache settings enabling "Cache alias hostnames". I just left the additional home URLs blank.

    This solves the login URL redirect, page caching works, SSL works as it should, and the only thing I lose is cross domain login.

  • Ken Kimbrell
    • The Crimson Coder

    Hello Dan-

    I am glad to hear that you were able to find a viable solution, or at least a workaround to the problem. We do apologize that the cross-domain login seems to not play nicely with W3TC cache plugin. We do try are best to make our plugins as cross compatible as possible with other plugins. However we do understand that sometimes plugins may not always play well together. Or they do, but certain features or configurations within the plugins are effected by one another. Normally the best option is to choose an alternative plugin that offers the same functionality and see if the new plugin is more compatible with our plugin. Or in your case, decipher as to whether the functionality that is effected is a dependency to the operation of your site.

    If there is anything else we can do to help. Please let us know.

    Take Care,

    Ken - WPMU DEV Support

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.