Search code examples
wordpressuploadsubdirectory

WordPress in subdirectory has wrong upload_dir


I have a WP installation in the root-folder, and some other WP installations in sub-directories

  • example.com => has WP-installation in root folder
  • example.com/project1 => folder named "project1" resides in root and has own WP-installation

everything works fine, except uploads.

Let's say, I'm in example.com/project1/wp-admin and want to upload a file:

Expected behaviour:

  • file is uploaded to /project1/wp-content/uploads
  • DB-entry is created in project1-database

Actual behaviour:

  • file is uploaded to /wp-content/uploads (root-folder)
  • DB-entry is created in project1-database

I've tried changing upload_dir, resulting into the same behaviour:

define('UPLOADS', 'project1/wp-content/uploads');

I also tried changing the wp_content_dir:

define( 'WP_CONTENT_DIR', dirname(__FILE__).'/project1/wp-content' );

But this gives me an error, like "Can't upload to /project1/wp-content/uploads/2018/09'.

What am I doing wrong here?


Solution

  • Ok, got it fixed now:

    I was on the right path with:

    define( 'WP_CONTENT_DIR', dirname(__FILE__).'/project1/wp-content' );
    

    The error that I got, was because I created the folder for the mounth by hand as root, and therefore the permissions were wrong.