If you want to use one installation of WordPress, you need to either run WordPress Multisite (which you do not want to do) with the plugin for domain matching, or force WordPress to accept any host name (domain) of the request for and serve content conditionally in each domain.
(The following assumes that you are running both example.com and secondary.com , and both of them are pointing to the same server where WordPress is installed. In addition, the following examples were pulled right out of my head without any real tests or verifications, it may or may not work as it is.)
Adopting WP accepts multiple host names for requests
Typically, WordPress is tied to a single name / domain, where it can serve pages and content. The domain is stored in the lines wp_options siteurl and home as http://www.example.com , for example.
You can override this value in wp-config.php with the PHP constants WP_SITEURL and WP_HOME . First you need to make sure that the main domain (for example, maindomain.com) is set correctly in the rows of the wp_options siteurl and home table. Then you need to configure the wp-config.php so that WP accepts any domain as such:
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
(Remember to configure HTTP and HTTPS if necessary.
Now your WP installation should open just fine when the domain is pointed to the server. You can have as many domains as you like, and all of them make WP download upon access.
Redirecting a page to another domain
You can use either .htaccess or WP code to redirect. If the redirection is application / site specific and should work anywhere, try using the WP code, which is likely to follow in the source code repositories, etc.
add_action('template_redirect', function () { $isMainDomain = strpos($_SERVER['REQUEST_URI'], 'example.com') !== false; // We are on primary domain and on domain.com/b if ($isMainDomain && is_page('b')) { wp_redirect('http://secondary.com'); exit; } // You need to validate child pages too and redirect where needed. });
Add this to the plugin or functions.php theme. Now, when someone accesses page b in the primary domain, they will be redirected to secondarydomain.com .
To achieve this with .htaccess, you can try the following
RewriteEngine on RewriteBase / // Redirect page `b` and all child pages to other domain. RewriteCond %{HTTP_HOST} example.com$ RewriteRule ^b/(.*)$ http://www.secondary.com/$1 [L,QSA,R=301]
Removing page skips from a page in WP
You now have a user sitting at http://www.secondary.com , but the user sees the front of your WP installation instead of the contents of page b .
With rewriting .htaccess, you can proxy these domain requests to a specific "subdirectory" if you need to.
RewriteEngine on RewriteBase /
This rule first checks if the request was against the secondary.com domain name. If so, the server rewrites all requests to the WordPress b page and its subpages.
Now that someone opens http://www.secondary.com , he should go to http://www.secondary.com/b and display the page instead.
(Note: I have not tested the rule above so that it may or may not work as is.
Permalink Fixing
You now have a problem with permalinks to page b . Getting permalink returns http://www.example.com/b when it should return http://www.secondary.com .
Adding a filter for permalinks should fix this problem:
add_filter('post_link', function ($link, $post) { if (is_admin()) {
This is a shallow approach that does not take into account media or user behavior. You need to confirm that both domains allow cross-start requests and that user session cookies are stored properly for cross-start sessions where necessary.
What I would like to offer is a study of how to connect to the media download process so that the two WP installations use the same directory and data. The same directory is accessible with the upload_dir filter, and attachments are saved similarly to messages, so you can duplicate uploads to two sites using wp_insert_post or the like.
In addition, you can use two WP installations with one user table, using some wp-config.php tricks.