I am trying to move the wp-content directory outside of the wordpress directory and hitting all kinds of weird problems. Even though http://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content_folder says you can do this, it seems that the directory structure is deeply wired into the WP code. For example, I get error messages like:

PHP message: PHP Warning:  file_exists(): open_basedir restriction in effect.
File(/srv/wp.content/themes) is not within the allowed path(s): (/srv/wordpress/:/tmp) 
in /srv/wordpress/wp-includes/theme.php on line 369

All I need to do is to move the uploads directory outside of the main hierarchy. I tried to symlink it as well but then I am getting permission errors.

Did anybody manage to successfully have the wp-content directory, or at least, uploads directory outside of the root directory?

2 Answers 2


You have to define WP_CONTENT_DIR and WP_CONTENT_URL:

const WP_CONTENT_DIR = '/path/to/new/directory';
const WP_CONTENT_URL = 'http://content.wp';

The new path must be accessible for read and write operation from the WordPress core directory. You might need a helper function to add the new directory path to the open_basedir list:

 * Add a new directory to the 'open_basedir' list.
 * @link   http://www.php.net/manual/en/ini.core.php#ini.open-basedir
 * @param  string $new_dir
 * @return void
function extend_base_dir( $new_dir )
    $separator = ':'; // all systems, except Win

    // http://stackoverflow.com/a/5879078/299509
    if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
        $separator = ';';

    $dirs = explode( $separator, ini_get( 'open_basedir' ) );

    $found = array_search( $new_dir, $dirs );

    // Already accessible
    if ( FALSE !== $found )

    $dirs[] = $new_dir;

    ini_set( 'open_basedir', join( $separator, $dirs ) );

Now call it like this:

extend_base_dir( WP_CONTENT_DIR );
  • Thanks @toscho. I actually found open_basedir in my php-fpm configuration and fixed it there. Wonder why Wordpress doesn't document this in the official documentation I linked...
    – Sasha O
    Feb 16, 2014 at 17:43
  • I am trying to get to a similar way for uploads directory. Any help?
    – user86113
    Feb 18, 2016 at 20:22
  • @IhabAbdel-Rahim Yes. Ask a new question.
    – fuxia
    Feb 18, 2016 at 21:00
  • @toscho wordpress.stackexchange.com/questions/218237/…
    – user86113
    Feb 19, 2016 at 16:22

Came here to find out how to move uploads outside the WordPress root. In the end I kept it as simple as creating a symlink and it works just fine.

$ pwd
$ cd ..
$ mkdir uploads
$ chmod 755 uploads
$ ln -sf /var/www/uploads /var/www/wordpress/wp-content/uploads

Source: Upload folder of Wordpress outside the project

For an existing project:

$ pwd
$ mv /var/www/wordpress/wp-content/uploads /var/www/uploads
$ chmod -R 755 /var/www/uploads
$ ln -sf /var/www/uploads /var/www/wordpress/wp-content/uploads

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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