Domain Mirror Plugin

WordPress 2.8.5: Works.
WordPress 2.8.4: Works.
WordPress 2.7: Works.
WordPress 2.6.2: Works.
WordPress 2.6.1: Works.
WordPress 2.5: DomainMirror seems to work with no changes on this version, as long as the 2.3 patch is in place.

Download: Domain Mirror v1.1

Download: Domain Mirror v1.2beta

Download: WP-DomainMirror WordPress 2.3 fix

If you have more than one domain and want to point both of them at the same WordPress installation, you’ll find that it doesn’t really work very well. WordPress creates it’s own internal URLs based on the settings in General Options. This Plugin allows multiple domains to be configured within WordPress and updates the Weblog Title, WordPress Address URL and Blog Address URL on-the-fly based on the value of $_SERVER['SERVER_NAME'].

This allows one installation to show different URL paths, tagline and blog title for each domain.

What it won’t do is make one domain appear to be two, or change your domain configuration. You need to do that yourself, or have your hosting provider do it for you.

To see it in action, you can access this site via http://McAleavy.org or http://LightPainting.org. Both point to a single WordPress installation, running on a single database.

NB: It doesn’t appear to work with WordPress MU.

New in v1.1

  1. You can now have a separate tagline on each domain.
  2. The Admin screen has a button to copy in the current WordPress configuration to save on typing.
  3. The Admin screen has buttons to clear content from whole domains and indivudual lines.

New in v1.2beta

This version is pretty new, contains quite a few changes, and may have bugs. Please use it if you’d like to help find them.

  1. Theme switching.
  2. SERVER_NAME / HTTP_HOST config option.
  3. “no admin screen” switch.
  4. More validation.
  5. Added “stripcslashes”

Installation

  1. Download and unpack the archive. If you downloaded the plugin from my site it will unpack to a directory named “AA-DomainMirror”, but if you got it from the WordPress plugin repository it will unpack to the direcotory “domain-mirror”. Either will work, but you may need to rename the latter to “AA-DomainMirror” if you have problems with some other plugins not seeing the changes. See below.
  2. Copy the whole AA-DomainMirror directory to wp-content/plugins/ If possible, don’t change the name of the directory, as the AA- at the start is a horrible hack to ensure that WordPress loads this plugin first. This is required as any plugin loaded before it won’t be able to see the changes it makes, so will behave as if it’s still on the default domain. This puzzled me for quite a while.
  3. Go to your Plugins page and activate Domain Mirror.
  4. Go to the Options -> Domain Mirror page and configure as outlined below.

Upgrade

Overwrite the old version with the new version.

Usage

When enabled, Domain Mirror will change the values of Weblog Title, Tagline, WordPress Address and Blog Address automatically. Where you have hard-coded the site name or a site URL into a post or page you should replace that entry with one of the tags provided. See below.

Configuration

Click the images to expand.

You will need to set up at least 2 domains that point to the same WordPress install. With Apache you can do that with Virtual Hosts. If you are using a hosted account there may be some way to set this up through the account configuration screens. On the host I use for this site, DreamHost, you do this by logging into the Panel interface and selecting Domains >> Manage Domains. Your first domain must be Fully Hosted. For the Domain you want to set as the Mirror, click the edit button. In the edit screen there are 5 options:

  1. Fully Hosted;
  2. Redirected;
  3. Mirrored;
  4. Parked;
  5. Cloaked.
DreamHost Mirror Settings

DreamHost Mirror Settings

Select the Mirrored option, and set Domain to mirror to the name of your Fully Hosted domain. Shown here is this setting for my lightpainting.org domain, which mirrors mcaleavy.org.


Options Before

Options Before

Your existing WordPress configuration should be left as it is. This will not be changed unless you press Save on this page when viewed from a domain other than the default. See below.


Domains Before

Domains Before

On initial activation, the Domain Mirror options screen will display a default blank entry. This default is defined in conf.inc.php – which can be edited to set different defaults. The post tags used to display the current setting of these fields in posts or pages are shown to the right. Add this text to a post or page and it will be replaced by it’s value for the current domain. This allows such posts to display properly from any configured domain.


First Domain

First Domain

Fill in the settings for the current domain, or press the Get Current Domain button to get the values from the database. This is recommended because the General Options page will show the Domain Mirror configured settings when accessed from another domain. If you then press Save on that page those options will be written to the WordPress settings, overwriting the original settings. If you don’t have those settings in Domain Mirror, they will be lost and the original domain will not function properly until they are re-entered. If Save is not pressed, the original values will be retained and will be used again when the plugin is disabled.


Changes Saved

Changes Saved

Click the Save button to record the changes. The screen will reload and display the Changes Saved banner.


New Blank Domain

New Blank Domain

To add another domain, click the Add New Domain button. The page will refersh with a 2nd blank domain.


Second Domain

Second Domain

Fill in the details for the 2nd domain, and click Save Changes.


SiteBefore.jpg

SiteBefore.jpg

Now, when viewed using the first domain, the site remains unchanged.


Site After

Site After

When viewed using the second domain, the site appears as if configured for that domain.


Options After

Options After

The General Options screen, when accessed from the new domain, now displays the details for that domain. These options, however, are coming from the Domain Mirror configuration and not from the WordPress settings. As noted before, if save is pressed on this page these options will be written to the WordPress settings, overwriting the original settings. If you don’t have those settings in Domain Mirror, they will be lost and the original domain will not function properly until they are re-entered.

To delete a domain, press the Delete Domain button and it will be removed from the page. This change will be written to the database when you next press Save Changes. If you delete all of the entries in Domain Mirror it will return to it’s default settings. If you wish to alter these defaults you can edit the file config.inc.php in the AA-DomainMirror directory. The “X” buttons on each line can be used to clear the contents of that line and the Clear All button can be used to clear the contents of that domain setting. Again, pressing Save Changes is rquired to make these changes permanent.

DaveMc, April 2007.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

  1. March 19th, 2008 at 00:43 | #1

    Hi,

    Perhaps you should rename the directory to “%%-DomainMirror” since there is a plug-in called “404 Notifier” which would sort ‘alphabetically’ before ‘AA’.

    I am just about to try this plug-in along with the hints on Mike Davidson’s blog regarding making a site mobile friendly.
    http://www.mikeindustries.com/blog/archive/2005/07/make-your-site-mobile-friendly

    I don’t know if I also need “WordPress Mobile Edition” as well. Guess I’ll find out.

    ~Andrew~

  2. February 18th, 2008 at 18:38 | #2

    Have a problem, huh. I made a new domain and uploaded a copy of the blog on it. Then uploaded your plugin.

  3. tash
    February 18th, 2008 at 06:12 | #3

    great plugin, thanks. been looking for something like this.

    I’ve tried this plugin with WP2.3. I am using cpanel so I added a parked domain from cpanel. Everything works fine but all links to images still point to the main domain.

    any help would be greatly appreciated.

    tash

  4. gestroud
    February 6th, 2008 at 14:35 | #4

    Hello,

    I get the following errors on a WP 2.3.3 install:

    Warning: require(config.inc.php) [function.require]: failed to open stream: No such file or directory in /xxx/home78a/xxx/xxx/xxx/wp-content/plugins/WP-DomainMirror.php on line 57

    Warning: require(config.inc.php) [function.require]: failed to open stream: No such file or directory in /xxx/xxx/xxx/xxx/xxx/wp-content/plugins/WP-DomainMirror.php on line 57

    Fatal error: require() [function.require]: Failed opening required ‘config.inc.php’ (include_path=’.:/usr/local/lib/php/’) in /xxx/xxx/xxx/xxx/xxx/wp-content/plugins/WP-DomainMirror.php on line 57

    I know the first two are just warnings, but the last one is a problem.

  5. December 18th, 2007 at 20:27 | #5

    Also, what are the implications for duplicate content penalties?

  6. December 18th, 2007 at 17:19 | #6

    Hi Dave, thanks for a great Plugin!

    Other than the back slashes (which you’re aware of, by the looks of things), all seems to be working fine.

    I’m sort of edging towards a similar scheme to Matt above. I don’t know if that’s within the remit of the plan you have for this Plugin or not.

    In addition to Matt’s suggestions, I’d be wanting to associate a web address to a specific category or web page…

  7. November 18th, 2007 at 20:29 | #7

    What if I want specific content to display per domain? For example… I have xyz.com and abc.com. So is there a tag I can put in like site-name-logo.gif so it loads either xyz-logo.gif or abc-logo.gif depending upon the url?

  8. kokolina
    November 8th, 2007 at 09:40 | #8

    using WP-2.3.1

  9. kokolina
    November 8th, 2007 at 09:40 | #9

    hi, thanks for this great plugin!
    I have a trouble:

    I did:
    install wordpress in: domain.com
    create a subdomain: 2nd.domain.com
    install plugin in: domain.com/wp-content/plugins/AA-DomainMirror
    configure everything as you detailed.
    and when I go to 2nd.domain.com, I get this message:

    “Forbidden
    You don’t have permission to access / on this server.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. ”

    I haven’t installed anything in the subdomain 2nd.domain.com….
    not even a index.php or anything… maybe this is the problem…

    thanks for the help! :D

  10. November 7th, 2007 at 03:20 | #10

    Hi! Thanks for this plugin.

    I have a feeling that this may be conflicting with my Search Widget function… it defaults to the main index page.

    Has anyone reported such a problem?

    Thanks
    peter

  11. November 1st, 2007 at 12:24 | #11

    I’ve just tried it with my WP2.3 my main domain is http://www.anujgakhar.com and I added another parked domain from cpanel http://www.cfcoder.co.uk . however, when I open cfcoder, it doesnt change any links at all. All links still point to anujgakhar.com
    any idea what I am doing wrong?

  12. October 23rd, 2007 at 19:41 | #12

    So, I installed the plugin to my “main” website server. I’m assuming that I need to upload all of my WordPress documents to the mirror site in order for the domain mirror to work correctly, right? Then via the plugin, all new posts and information will be updated in the domain mirror as well?

  13. October 22nd, 2007 at 00:59 | #13

    I just posted a fix for WordPress 2.3. Thanks to SecondeView for the solution and sorry for the delay. Download the file from the link at the top of this page and replace the file WP-DomainMirror.php

    Dave

  14. October 20th, 2007 at 12:48 | #14

    It’s working, wonderful: http://www.kitab.nl = http://www.fartattou.com

    many thanks Dave fopr this plugin

  15. October 19th, 2007 at 13:30 | #15

    Dave,
    my blog (kitab.nl) is censored in Tunisia (DNS censorship and not IP). I’m planning to install AA-DomainMirror to enable people bypass the ban by accessing my blog through the 2nd domain name. My question is, will it possible to change the 2nd domain name whenever it is being blocked in Tunisia?

    thanks

  16. DaveB
    October 1st, 2007 at 22:03 | #16

    Dave:

    My problem is sort of the reverse. I have WP set up on a domain that I don’t want to expose. It powers four other domains.

    We’re doing this right now with an old installation of ezPublish and want to kick over to the fantastic features of WP, which we’ve been working on for months.

    So:

    http://www.masterdomain.com hosts the admin software and is, in fact, the only “real” domain.

    http://www.domain1.com
    http://www.domain2.com
    http://www.domain3.com and
    http://www.domain4.com

    Are all pointed at their respective home directories (www.masterdomain.com/domain1, etc).

    This much, we can do in WP and .htaccess.

    But our current installation of ezPub also rewrites the domain name so that

    http://www.masterdomain.com/domain1

    shows up in the browser as

    http://www.domain1.com

    ..and all subpages and sections show up under their aliased domains.

    We can’t find a way to do this in WP.

    Can your plugin be modified to handle this issue? Do you know of a solution? We are willing to help fund development of a plugin to do it, or for any useful answer.

    Thanks,
    Dave

  17. September 30th, 2007 at 13:02 | #17

    I’ll be upgrading this site to WordPress 2.3 next week, so will deal with the plugin issues then and push out a new version. Sorry for the delay – I’ve been tied up with other things recently.

    Google seems to be smart enough to recognise the difference between the same site on multiple domains and the same content on different sites – at least I’ve never had any problems. Both my domains see hits from Google, so don’t appear to be filtered.

    Dave

  18. September 27th, 2007 at 00:31 | #18

    What’s about Google Duplicate Content Filter ?!

  19. Peter Lurie
    September 25th, 2007 at 14:28 | #19

    Dave!

    I really need your Plugin for WP2.3! Any plans to upgrade?

    Many thanks
    Peter Lurie

  20. September 16th, 2007 at 15:52 | #20

    this used to work so well for me and now it dont anymore. i dont remember having to go and forward domains like it says to now and i just cant get it to work

  21. September 4th, 2007 at 20:50 | #21

    Fawaz,

    Are you running a version later than 2.2.1? That’s what I’m running here, and so far I haven’t tried it on anything later. I’ll try the latest version and see how it goes.

    Dave

  22. September 3rd, 2007 at 13:21 | #22

    The plugin (v1.2Beta) seems to be incompatible with WordPress 2.2.x and above. I tried to activate the plugin on my blog and it gave me an error > “Plugin not activated as it generated a fatal error” or something like it.
    Can you tell me why is this happening?
    I just downloaded the zip from your site and uploaded the AA-DomainMirror Directory to the plugins folder as per your instructions.
    So please advise Dave.
    Thanks

  23. August 22nd, 2007 at 12:57 | #23

    Alex,

    I don’t have any experience with cpanel, so I don’t know if it allows the setup of additional domains as Virtual Hosts. If the parked domains are all pointing at the same directory, I would have expected that to work. If they’re just forwarding to your existing domain, it won’t, as the script won’t see a change to the incoming domain.

    Dave

  24. August 19th, 2007 at 14:37 | #24

    I am not using dream host, but my own host, there is no such thing as “mirror” domain. is there any way to make it work with regular cpanel?

  25. August 19th, 2007 at 12:20 | #25

    Alex,

    If you’re using DreamHost, then you need to change the configuration of your Parked domains to Mirrored. I’ve added a section to the Configuration instructions with a screen shot to show how this is done.

    Dave

  26. August 19th, 2007 at 07:25 | #26

    Sorry Dave, i don’t understand what is “mirror domain setting on your dreamhost. i have 5 parked domains at main one where WP installation is. All domains have DNS record pointing at the host. It doesn’t seems to work. What am i missing here?

  27. August 15th, 2007 at 03:11 | #27

    my god this is perfect…..works perfect to. this really saves me thanks

  28. August 13th, 2007 at 10:15 | #28

    Thanks

  29. August 13th, 2007 at 10:06 | #29

    The tags [ dmWpAddr ] and [ dmBlogAddress ] are used to insert the URL of the current site into a post.

    For example, if you want to add a link to another static page on your blog to a post it’s usually best to do this with a full path (if you use a relative path the link sometimes won’t work from an archive page). If you do this you’ll want that path to change when the site is accessed from a 2nd domain, so the tags allow you to insert the WordPress Address and the Blog Address dynamically into a posted URL.

    [ dmWpAddr ]/wp-content/graphics/something.jpg

    Dave

  30. August 3rd, 2007 at 15:42 | #30

    can u help me use the domain mirror, to show only a tag?
    what should i do with the dmWpAddr and dmBlogAddr fields?

  31. July 28th, 2007 at 08:30 | #31

    Luis,

    Yes. Set your webserver up to point both domain names to the same directory on the server. With Apache you can do this by setting up a Virtual Host.

    Dave

  32. Luis
    July 27th, 2007 at 04:38 | #32

    Hi, i have wordpress on http://www.domain.com/wp ( /www/domain.com/htdocs/wp ) and i want to make it accessible under myname.com, this last domain, has to be an alias for domain.com, right? because i can also point it to the same location in the server file system (/www/domain.com/htdocs )

  33. July 12th, 2007 at 16:47 | #33

    Thanks, Dave. I’m using a custom theme. Will follow your suggestion, upgrade to 1.2beta, will see.

    Alexx

  34. July 12th, 2007 at 13:22 | #34

    Alex,

    If you let me know what versions of WordPress and Domain Mirror you’re using, and what theme, I’ll try and reproduce it. There’s a possibility that it might have something to do with the Apache variable being used to detect the incoming URL – 1.0 and 1.1 use SERVER_NAME, whereas that can be changed in the conf.inc.php in 1.2beta. Someone else discovered that HTTP_HOST works better in some configurations.

    Dave

  35. July 11th, 2007 at 22:00 | #35

    Thanks for replying, Dave. There is a lot of customization, but with get_option. Even comments urls are not converted, though.

    Alex

  36. July 11th, 2007 at 19:56 | #36

    Alex,

    If it’s changing some URLs and not others it may be a plugin loading order issue – any plugin that loads before Domain Mirror will not see the modified values. I had a similar problem with Ultimate Tag Warrior on my sidebar. Where do you have the plugin installed?

    It could also be some custom code that isn’t using the standard get_option() call to get the WordPress and Blog URLs. Have you done any customising?

    Dave

  37. July 11th, 2007 at 09:20 | #37

    ok, I finally manaed to install the plugin, but it only changes sidebar’ posts urls. Please look at http://www.samsonblinded.com/blog – most of the links did not convert.

    Thanks,
    Alex

  38. July 10th, 2007 at 23:36 | #38

    Have a problem, huh. I made a new domain and uploaded a copy of the blog on it. Then uploaded your plugin. But when I went to activate the plugin, /wp-admin redirects to the main domain. In other words, I cannot access a new domain’s blog to activate your plugin.
    The problem, of course, has nothing to do with your plugin, but I cannot figure out how to solve it. Any suggestions are welcome.

  39. June 23rd, 2007 at 18:51 | #39

    I’ve not yet done any testing with WordPress MU, so it may be an issue with that – what’s happening when you access WP from the other domain?

    Dave

  40. June 23rd, 2007 at 18:39 | #40

    I too am on DH and using a MU WP install, and I cant get the second domain (actually a subdomain) to work, even thought I’ve setup the second domain as mirror on DH panel.

  41. Naveen
    June 18th, 2007 at 07:22 | #41

    Thanks for your response Dave :-)
    It was very helpful, even i will try and get back to you.

    - Naveen

  42. June 15th, 2007 at 22:09 | #42

    Naveen,

    I’m not sure how plugins work under WordPress MU as I’ve never looked at it, so I’m not sure if an install of domain mirror would affect all users on the MU system or just those with it active. It depends on how MU handles filters. I suspect it will work, but I’ll try and give it a test and see what happens.

    On the Apache configuration, the virtual host would need to point to the same directory as the main host if that can be done. I have a possible change that may make that setup work better – I’m currently looking a SERVER_NAME to determine the incoming URL, but it’s might be better to look at HTTP_HOST for instances where SERVER_NAME doesn’t change.

    Dave

  43. Naveen
    June 15th, 2007 at 08:06 | #43

    I got this plugin installed. I have few questions

    1) Will this work for wordpress-mu-1.2.1?
    2) I am using apache webserver that runs a site (default wordpress-mu) domain. Once i activate this plugin will the alternate domain will be directly accessible in browser or we should create virtual hosts in apache, in order to access this in browser?

    Thought welcome.

    Thanks
    Naveen

  44. June 10th, 2007 at 10:18 | #44

    I install it as it under domain-mirror, will try the AA- and see if it’s works. Thanks

  45. June 10th, 2007 at 10:05 | #45

    Hatem,

    I suspect that WordPress is probably loading the Mobile plugin before the Domain Mirror plugin. Do you have it installed in the directory “wp-content/AA-DomainMirror” or “wp-content/domian-mirror”? I had similar problems with Ultimate Tag Warrior that could only be resolved by changing the directory name as WordPress loads plugins in alphabetical order. I’ll download that plugin and investigate, and add some stripslashes.

    Thanks,
    Dave

  46. June 10th, 2007 at 09:30 | #46

    Excellent plugin ! I tried to use it for the .mobi version of the website, but it’s not working. I’m using the WordPress Mobile plugin by Andy Moore (http://www.andymoore.info/wordpress-mobile-plugin/).

    Btw there is a bug Line 111, 115, 290 and 329 need to add a stripcslashes(). Just add a slash in the title or description to notice it.

  47. June 6th, 2007 at 20:47 | #47

    Michael,

    Yes, in theory I think this plugin would allow you to have 2 identical servers on 2 separate domains share same database. I’m not sure why you’d want to do that though as the net effect would be the same as pointing both domains at the same server, except you’d have 2 installs to upgrade and maintain. I’m also not sure if it’s safe to have 2 WordPress installs access the same database at the same time. There’s a chance that they might cause some data corruption by stepping on each other’s writes. I don’t know enough about mySQL to be sure.

    I’ve been thinking about the possibility of changing theme based on the domain. It depends on how much the configuration changes when the theme is swapped, and whether those options can be filtered. If they can it should be relatively straightforward. I’d was also considering having different sets of posts show on either site, but how practical that is I don’t yet know – it might be easier to just run 2 WordPress installs for that.

    The next version, running here, allows the tag line to be changed too, and upgrades the Admin page a bit. I’ll try and get that posted tonight sometime.

    Dave

  48. June 6th, 2007 at 13:53 | #48

    I have a couple of questions.

    1) so long as the sites share the same db (& are true file & .htaccess mirrors of each other), why would they need to live on the same server?
    2) how difficult would this be to extend to having differing themes based upon domain? (My thoughts are to be able to have a much more robust version of MU WP… and being able to have a central control point for administration of simple sites based on WP that share content.)

  49. June 5th, 2007 at 22:39 | #49

    It looks like those two domains are pointing at different sites. You need to set both domains to point to the same site – the plugin will then see the incoming doamin name and change the WordPress configuration. A “forward” from one domain to the other won’t work as WordPress will still see an incoming connection to the original domain.

    With my webhost (dreamhost.net) that’s done by setting up what they refer to as a “domain mirror”, but I suspect that this is simply setting the DNS on both domains to point to the same directory on the server. You can tell if you have that set up properly by looking at the “Current Domain” display in the Admin Page. This should be different when using the other domain.

    Dave

  50. June 5th, 2007 at 22:06 | #50

    I configured my two domaind (crkdesigners.com and bent101.com) as per your instructions but only the first domain (bent101.com) works! What am I missing? My WordPress is located as: http://www.bent101.com/wordpress

Comment pages
1 2 3
  1. June 4th, 2007 at 20:12 | #1
  2. July 6th, 2007 at 06:43 | #2
  3. September 22nd, 2007 at 21:38 | #3
  4. March 31st, 2008 at 05:10 | #4
  5. April 27th, 2008 at 12:21 | #5
  6. April 27th, 2008 at 12:28 | #6
  7. May 4th, 2008 at 18:50 | #7
  8. May 15th, 2008 at 19:18 | #8
  9. September 2nd, 2008 at 01:44 | #9
  10. November 19th, 2008 at 14:34 | #10
  11. December 31st, 2008 at 08:01 | #11
  12. December 31st, 2008 at 13:46 | #12