We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29246
    • 12 Posts
    Hello,
    I was wondering can you move the "config.inc.php" file out of the manager>includes folder to above the publicly accessible folders. For example, the area you access as soon as you login to your FTP. I remember Joomla could do this.

    Thanks
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Not at this time; or at least not without hacking a number of core files. You could more easily move the database access information to an external file, and include or require that file in the config.inc.php file.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 29246
        • 12 Posts
        Thanks a lot! That is exactly what I want to do, do you know how I can do that?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          As long as your php is able to access directories above the web root, just create a file (maybe named "dbaccess.php") and cut/paste the db access section from the config.inc.php file. Replace it with
          require_once("../../../dbaccess.php";

          then put the dbaccess.php file one directory above the web root. If you put it somewhere else, you’ll have to adjust the path; what the above is saying is "move up three directories" (i.e. from where the including file is, includes, to -> manager to -> web root to -> one above web root). You could also use a hard-coded full path here instead of this relative path.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 29246
            • 12 Posts
            Thank you very much.
              • 29246
              • 12 Posts
              For testing, I created the dbaccess.php file and placed it in the same directory.
              I removed this code from config.inc.php, and placed it in dbaccess.php.

              $database_type = 'mysql';
              $database_server = 'localhost';
              $database_user = 'user';
              $database_password = 'pass';
              $database_connection_charset = 'utf8';
              $database_connection_method = 'SET NAMES';
              $dbase = '`db_table`';
              $table_prefix = 'modx_';
              


              and replaced it with
              require_once("dbaccess.php";


              but the site just loads a blank page.

              Any ideas?

              Thanks so much.
                • 3749
                • 24,544 Posts
                You’ll definitely want to close the parentheses in your require_once statement. wink

                If that doesn’t work, try:

                require_once("manager/includes/dbaccess.php");


                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting