• I have subdirectory multisite running fine on an apache name virtual host server, where it is coupled to an MVC application that has its own signup and login process and database. The MVC application and mu plugins cooperate to map MVC userids to wp users, and any access to a wp site causes a behind-the-scenes login to the wp user corresponding to the current MVC user; if no MVC user is logged in, access to any wp site is blocked.

    Now I want to add a different name virtual host with the same document root as the original – the MVC application uses the server name to control certain aspects of its presentation, but both applications use identically the same database, and I want both to share identically all subdirectory blogs and their content. E.g. if right now https://www.example.com/wp/blog accesses a multisite blog named blog, I want to be able to alias https://alias.www.example.com to https://www.example.com, and have https://alias.www.example.com/wp/blog access identically the same blog.

    In my subdirectory multisite, the blogs table has both the domain and the path for each blog as it was created. If I try to access a blog through the alias domain, then I get the error “Error establishing a database connection”. Presumably this is because the constant DOMAIN_CURRENT_SITE was defined to be $_SERVER[‘SERVER_NAME’] in wp-config.php, and there is no entry in the blogs table with that domain. But if I edit wp-config.php to define DOMAIN_CURRENT_SITE to match the original domain name regardless of SERVER_NAME, then database access is okay, and everything works – *EXCEPT* that requests get redirected to the original domain, losing the fact that the access was made through the alias, and losing the appearance changes that I want to see for accesses made through the alias.

    This all seems reasonable for situations where different subdomains have different content. But can you think of some low-level plugin/tweak/hack approach to allow access through the alias, without getting redirected back through the original name stored in the database? Could I, for example, create multiple entries in the blogs table having the same blog_id and path, but different domains? I can give that a try, but I’m concerned that if it should work in initial experiments, I could be setting myself up for future disaster/corruption.

    Any advice would be appreciated.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter sootsnoot

    (@sootsnoot)

    Quick experiment shouldn’t have been necessary if I’d been familiar with the table definitions: blog_id is the primary key, so it isn’t possible to have more than one row with that value.

    Next idea? ??

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Generally speaking, WordPress doesn’t like having two domains be the same thing. That’s why it has a site/home URL setting. Those are meant to be ONE site, one URL.

    I gather the MVC is what’s requiring this ‘my MVC domain must match my WP domain’?

    Thread Starter sootsnoot

    (@sootsnoot)

    Thanks for looking at this. I realize I’ve got a fairly unusual situation, so finding out I can’t really get exactly what I want through plugins (without touching core files) might well be the answer. What I’m asking sort of directly contradicts the behavior of WP subdomain multisite. The only thing in my favor is that I set up only subdirectory multisite, so my little parochial interpretation of what that might mean is that wordpress should ignore the subdomain and just look at the path in requests ??

    So yes, you’ve hit the nail on the head. In more detail, accessing the MVC application through different subdomains is sort of accessing only a single site in the sense that 99.9% of the sources are the same (through symbolic links), and there is only one MVC database with the result of queries not depending on which subdomain is used (though MVC application code might interpret or format query results differently depending on the subdomain). Thus the subdomain is used only as sort of a global implied query parameter to the MVC application, and I’d like to be able to do the same thing with the WP installation that goes with it.

    I’ve got workarounds that avoid the handful of unexpected behavior kinds of problems that can occur when wordpress redirects to the main server. But one that I don’t know how to workaround is that if a user of the MVC application accessed through a subdomain clicks a link to a blog, then the browser’s address bar changes to the servername of the main site with the subdomain stripped off.

    Thanks again for looking at this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can I force different domains to be treated as the same?’ is closed to new replies.