Can I force different domains to be treated as the same?
-
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!
- The topic ‘Can I force different domains to be treated as the same?’ is closed to new replies.