Is it possible to change a setting so that wp-config.php could be moved up two directory levels (instead of the default 1 level)? This would allow the core WP files to be moved from public_html to a subdirectory, while simultaneously allowing wp-config.php to be moved above public_html and thus not publicly accessible.

1 Answer 1


Yes, there is a great example of how to accomplish this in the top answer for the question: Is moving wp-config outside the web root really beneficial?

The section titled "How to move wp-config.php to any location on your server" provides the following solution:

But what if you've moved [wp-config.php] somewhere else? Easy. Create a new wp-config.php in the WordPress directory with the following code:


/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

/** Location of your WordPress configuration. */
require_once(ABSPATH . '../phpdocs/wp-config.php');

(Be sure to change the above path to the actual path of your relocated wp-config.php file.)

If you run into a problem with open_basedir, just add the new path to the open_basedir directive in your PHP configuration:

open_basedir = "/var/www/vhosts/example.com/httpdocs/;/var/www/vhosts/example.com/phpdocs/;/tmp/"

That's it!

  • Thanks Dave! Now, I just want to make sure I understand the path. If wp-config.php is in /root and Wordpress is in /root/public_html/blog then the path would be '../../wp-config.php' ? Thanks again.
    – Greg
    Mar 20, 2013 at 16:50
  • Yes @Greg, that would be the correct path value for you're scenario. Mar 20, 2013 at 17:13

Your Answer

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

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