Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

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:

<?php

/** 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!

share|improve this answer
    
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 '13 at 16:50
    
Yes @Greg, that would be the correct path value for you're scenario. –  Johannes Pille Mar 20 '13 at 17:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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