1

Is possible to use a subdomain, for example: media.mydomain.com pointed to /var/www/mediauploads, for two different domains?

Since I have mydomain.com and mydomain.it blogs, would be nice to upload files directly in one folder instead of duplicating the images when I write new articles in english and italian.

Hope someone can help! Thanks

1

2 Answers 2

2

First, create the folder/directory or the subdomain you want to use for your WordPress uploads, make sure it has the correct permissions and is writable.

In your wp-config.php file which is in the root of your WordPress installations, you can add the code below. Do this on both your WordPress installations and modify the location to that of yours.

define('UPLOADS', 'http://images.mydomain.com');

Make sure you place that line somewhere just above this line:

require_once(ABSPATH.’wp-settings.php’);

This will now set the custom location for your uploads to be the same location on both installations.

However, when you upload files to the server using WordPress uploader, it makes a record of it in the database. The media library references what's in the database, not what's in your file system.

So you will now find that images uploaded via the media library on the other WordPress installation are not visible in the other WordPress media library even though you will find the images exist if your browse to your uploads location on the server via FTP.

You would have to write something from scratch that scans through all the images within the new uploads sub directory and adds references to these into the database on the site that was not used to upload them.

I have also checked and found this for you. I have not used it but looks promising. Add From Server plugin

0

The easiest way to do this is to have your two sites in a Wordpress Multisite instance. this way you can share a common Media Library between your two websites.

Then of course you can define your uploads directory to be something else than the default folder, that could be served by a different subdomain.

Try this plugin : Network Shared Media

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.