• Resolved ArielZusya

    (@arielzusya)


    I’m thinking about using WP for my wedding website. In a fleeting attempt to be clever I purchased two domains, “ariellovesdana.com” and “danalovesariel.com”. The idea is simple, allow the user to find the site however they think of us (her first or me first). My intention is to put nearly identical info on the site but I’d like to have the domain the user entered through remain (so I can track how much traffic each gets… just for personal curiosity). Is there a way to initialize WP on both sites but have them point to the same DB without messing things up on the backend? I have both sites hosted under the same shell so they can both get access to the same DB without any fuss. I was thinking about the wp-config.php file and the prefix portion… that message about changing the prefix if you have more than one site looking to the db… and I was thinking if I don’t change the prefix each site will find the same info in terms of posts and such but will load that info into the site it was called from. Can I do that? Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Majority of the things can be shared, but the one thing that would need to be different because of the differing domain names would be some of the entries in the Options table.

    Your best bet would be probably to modify WP lightly to grab the Posts/Comments from the same location while keeping different tables for other site-specific things.

    Regards

    Here’s what I’d recommend (only works if the tables for both blogs are in the same database):

    First, choose which blog acts as primary, that is the blog the other will “slave” off of for posts and whatnot.

    Next, decide which elements the secondary blog will access on the primary. You’ll want posts and categories to be the same, but how about users? Or links?

    Finally, edit the secondary blog’s wp-settings.php (in the blog’s root). Look in it for this section:

    // Table names
    $wpdb->posts = $table_prefix . 'posts';
    $wpdb->users = $table_prefix . 'users';
    $wpdb->categories = $table_prefix . 'categories';
    $wpdb->post2cat = $table_prefix . 'post2cat';
    $wpdb->comments = $table_prefix . 'comments';
    $wpdb->links = $table_prefix . 'links';
    $wpdb->linkcategories = $table_prefix . 'linkcategories';
    $wpdb->options = $table_prefix . 'options';
    $wpdb->postmeta = $table_prefix . 'postmeta';

    Assuming the primary blog’s table prefix is wp_, for each table shared between the blogs change $table_prefix to 'wp_', like so:

    // Table names
    $wpdb->posts = 'wp_posts';
    $wpdb->users = $table_prefix . 'users';
    $wpdb->categories = 'wp_categories';
    $wpdb->post2cat = 'wp_post2cat';
    $wpdb->comments = 'wp_comments';
    $wpdb->links = $table_prefix . 'links';
    $wpdb->linkcategories = $table_prefix . 'linkcategories';
    $wpdb->options = $table_prefix . 'options';
    $wpdb->postmeta = 'wp_postmeta';

    Note I’ve modified just those above that are required to keep posts “mirrored” on both blogs. The other tables are up to you. At minimum keep $wpdb->options as is, to retain the settings for the blog (including blog name, permalinks, and so on).

    Doing it this way will require keeping this file–or at least the changes–untouched during upgrades to your WordPress installation. Keep that in mind.

    Couldn’t you save yourself a lot of work and simply redirect one of the sites to the other?

    Thread Starter ArielZusya

    (@arielzusya)

    Shadow: As I mentioned initially, I want to track which site users are using. Further, for mostly political reasons, I don’t want the user to choose to go to danalovesariel and have it redirect them to ariellovesdana as that message might be something about dominance. Silly, I know, but for anyone who has gone through the pre-marriage and marriage games, they know how much such little ripples can rock the boat.

    To the rest: Thanks for the ideas. I’ll give them a go and let you know how they turn out. Thanks for the help!

    Thread Starter ArielZusya

    (@arielzusya)

    Looks like it worked… Thanks again for all your help!

    Looks like you sorted it out, but can you not simply look at the server stats and look at entry page? You could then track which domain was hit more, even with a redirect.

    Thread Starter ArielZusya

    (@arielzusya)

    miklb – you’re right… I absolutely could… but I’d still worry that some family member or friend or something would see the domain changing in the address bar and take it the wrong way. This is just easier than having to explain. *GRIN*

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Two domains, NEARLY identicle blogs’ is closed to new replies.