• Hi Guys,

    I would like to run on two completly different domains the same website (only different layout). I will use one as main website where I make the posts (just like now) and the second site should have the same post too. The same database for two domains and two installs of wordpress should do the trick right?

    I found https://rephrase.net/box/word/multiply/ and https://mu.www.ads-software.com/ but they both are note made for this exactly, are they?

    Could somebody point me the direction. I dont have the second domain yet but for testing I can install wordpress local on Xampp.

    Thx!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The same database for two domains and two installs of wordpress should do the trick right?

    Nope.

    One of the fields in that database is the URI address of the blog. Thus, the db will only work for one blog.

    I’d suggest looking at the Syndication plugins and set things up so you post to blog A and blog B “pulls” content from A.
    https://codex.www.ads-software.com/Plugins/Syndication

    Depending how good you are with CSS/XHTML you could do this quite simply.

    In the header.php where you set the .css you could check what the domain is and then set the .css file accordingly.

    This would allow you to load a differnt .css file for each domain which in turn gives you the ability to change the look and feel of the site when really its just using the same XHTML and DATA, kinda like csszengarden style ??

    Another option would be to modify slightly the wp-config.php.

    I suppose that you have both domains pointing to the same server directory, i.e. one is fully hosted and the other is just parked on top of the first one. I’ll call then Primary Domain and Secondary Domain, respectively.

    A small step-by-step for my idea:

    1. Copy WordPress to your server web directory
    2. Open wp-config.php and seek for
      $table_prefix = 'wp_':

      and replace it by


      $whatDomain = $HTTP_SERVER_VARS["HTTP_HOST"];

      if (eregi("your-hosted-domain.com",$whatDomain)) {
      $table_prefix = 'yourhosteddomain_';
      } elseif (eregi("your-parked-domain.com",$whatDomain)) {
      $table_prefix = 'yourparkeddomain_';
      } else {
      die('This shouldn't never happen!');
      }

    3. On Primary Domain you run install WP as usuall
    4. On Secondary Domain you also run install WP
      Altough it is the same application and the same database the modification above will do the trick to seperate installations
    5. On Secondary you install FeedWordpress and properly set it up or you can also use Friends RSS too
    6. Tweak as much as you need the system to comply with what you want.
    7. Then you can start posting on Primary Domain.

    When FeedWordpress at Secondary Domain pulls the RSS from Primary Domain you’ll have what you wanted, right?

    The other option to have only one database and table for both domains but using diferent layouts will required much more coding.

    Hope this will help you.

    None of the solutions (?) offered deals with the fact that you cannot have 2 domains in the wp_options table for “home” or “site_url”. Those valuies are stored in the 1 (one) database the OP wants – so how do you build 2 domains on it?
    Just curious…

    Moshu – really?

    My post addressed that. In this thread.

    moshu is quite right, but the way i would have set it up would be so that the templates would not use any form of site URL and would just use relatove linking…

    so all linkes would be just /what-ever-you-want/

    ie:
    https://www.domain-one.com/what-ever-you-want
    https://www.domain-two.com/what-ever-you-want

    They would then both pull the same data, but the stylesheets would be differnt depending on the domain.

    • Same webspace
    • Different domains (hosted and parked)
    • Same Database

    It is rather easy. Just required a little “thinking”.

    #1 Open your theme’s “index.php”

    #2 Replace…

    getheader();

    by


    $whatDomain = $HTTP_SERVER_VARS["HTTP_HOST"];

    if (eregi("your-HOSTED-domain.com",$whatDomain))
    $headerStyle = '/hosted-header.php';
    else
    $headerFile = '/parked-header.php';

    if ( file_exists( TEMPLATEPATH . $headerFile ) )
    load_template( TEMPLATEPATH . $headerFile );
    else
    load_template( ABSPATH . 'wp-content/themes/default/header.php');

    It is usually the first thing on your theme’s file.

    Then in each domain-related header file you MUST hardcode everything related to where is the stylesheet since you cannot rely on Bloginfo() function to do that.

    This suggestion allows you to future upgrade WP without big effort.

    There are surely other ways, of course, but I pointed here some directions. It is always hard and implies coding. Ok!

    You have here already a few ideias. Poke around and you surely get something nice for your case.

    Better explaining Phunky’s ideia as I understood it.

    • Two fully hosted domains in the same server
    • Two diferent template designs
    • One MySQL database

    This will mean that, for instance, you will have two full WordPress installations:

    #1 at /home/domainone/www/
    #2 at /home/domaintwo/www/

    And, for instance, the MySQL database at localhost

    You then create two diferent themes and put:

    #1 at /home/domainone/www/wp-content/themes/yourtheme/
    #2 at /home/domaintwo/www/wp-content/themes/yourtheme/

    Altough those themes could be completely different they MUST have exactly the same name and the same directory name as you can see above. Else the system won’t work at all.

    Set up both domain config files to point to the same database and just run install on one of them and configure it to use yourtheme

    Remember that if you install a plugin in one of the domains you must copy the files also to the other domain.

    Remember that users access both domains.

    With this you will waste some space but will have two independent websites using the same domain.

    Hope that all this options solve your problem without too much problems. Free support from me on this issue ends here. Others may help…

    I can’t imagine how that would work.

    I guess I’m missing the part where you addressed the fact that each blog install has its URI values stored in the database.

    humaneasy: thats not what i meant at all…

    1: Install WordPress like you would on domain1.com
    2: Create your Theme in a way that it get all its presentation layout via the stylesheet (like cssZenGarden)
    3: Create both you domain1 and domain2 stylesheets with there differnt layouts/designs
    4: In header.php instead including the stylesheet via bloginfo(‘stylesheet_url’) use something like this

    <?php
    $stylesheet = ($HTTP_SERVER_VARS["HTTP_HOST"]=='www.domain1.com'):'domain1.css'?'domain2.css';
    ?>

    (note the above would of course not load the stylesheet its just declaring which to use

    5: Sorted, depending on the URL it will load a differnt stylesheet and display the layout needed.

    Of course if your not too great with CSS/XHTML then this could be a bad way to go as it depends on you setting out you XHTML in a way that will easily allow you to change the design via CSS instead of XHTML ??

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Apologies for a long reply, this one is wordy.

    My first reaction to this was “Why would you want to do that? Just RSS feed, use a sync’ed second database, something.”

    Which later on became a morbid, watching a train wreck kind of question “How would I do this?” ??

    Note that I still think this is a bad idea but this might be a step in the direction you want.

    Try this:

    domain1.com is the real blog with the real database.

    domain2.com is the duplicate that will contain the same posts, pages, and what not just use a different theme. Oh and domain2.com needs to be an Apache web server.

    In domain2.com Apache conf file enable mod_proxy, mod_proxy_http, mod_ext_filter and add these lines to the conf for domain2.com (.htaccess won’t/shouldn’t work)

    ProxyRequests off
    ProxyPass / https://domain1.com/
    ProxyPassReverse / https://domain2.com/

    ExtFilterDefine fixtext mode=output \
    cmd=”/usr/bin/sed s/domain1.com/domain2.com/g”
    SetOutputFilter fixtext

    ProxyRequests off ’cause open proxies are evil. The ProxyPass commands are so that requests going to domain2.com will cause the web server to pull the pages from domain1.com.

    The ExtFilterDefine and SetOutputFilter are to take the pages that domain1.com feeds the web server and modify the web page content so that all domain1.com references are changed to domain2.com. Little things like URL’s, style sheet etc. WordPress generates html code with the real blog references and these need to be changed.

    Now to see this in action go to these two URL’s

    https://wp.dembowski.net/

    https://dixie.dembowski.net/index.php?wptheme=Tarski

    The first one is the real URL of my wordpress blog, the second one in the fake domain2.com. I am using Boren’s terrific theme switcher but it should not be to difficult to modify Boren’s plugin so that the referer is checked and sets the cookie.

    Yes the second URL is a cheat for now. I’ll try to see if I can hack Boren’s plugin to check the referer and set the cookie that way.

    These two web servers are virtual and on the same box. But the domain2.com does not care at all; the original domain1.com is not modified in anyway.

    GREAT GUU DO NOT ATTEMPT TO MANAGE WORDPRESS VIA THE SECOND DOMAIN! I have no idea what the sed command would do to the admin interface output or your selections. Commiting any changes to the database using the second domain would be bad.

    The drawback is that I was unable to make it work by adding a fake directory (i.e. domain2.com/somepath/) so the directory structure on the duplicate will have to match the directory structure of the original blog.

    hbalagh

    (@hbalagh)

    I was able to do this just now, at least im pretty sure I did it like you wanted… I am still working on the layout of my style of my new one so don’t rate it lol

    https://www.heathersblog.com is my original blog
    I just recently decided to purchase my firstlast.com

    at https://www.heatherbalagh.com (nothing on the main dir right now)

    so added a photography section and a blog section

    https://www.heatherbalagh.com/blog same exact post and comments from my original blogs db comments can be left from either url and still show on the other

    That’s exactly what I’m looking to do Heather. Actually all I really want to do is change the header photo when one uses the second domain name.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘2 domains 2 layouts 1 database’ is closed to new replies.