Search code examples
phpjoomlacontent-management-system

How to move Joomla's configuration.php file above the root folder in a web host?


I have installed a security solution in my Joomla website,and it's suggest that to put the configuration.php file above the Public_html Folder,how could it be possible?

how to tell the CMS to recognize the new location?

is the solution would be valid in all versions of the Joomla CMS? ,if it's not,so please write:

1st:Joomla 2.5 Solution.

2nd:Joomla 3 Solution.


Solution

  • you would need to modify the defines.php file located in the includes folder.

    Specifically this line:

    define('JPATH_CONFIGURATION', JPATH_ROOT);
    

    And change JPATH_ROOT to the correct path.

    But the problem with this is that you are modifying a core file so if an update changes the defines.php file it will overwrite your changes and will break your setup. You will need to reedit the file.

    Also the JPATH_CONFIGURATION constant may be used for other things within the CMS that are not specifically trying to get the configuration.php file so make sure to check that it will not adversely affect other parts of the cms before doing this in production.

    Alternatively you can change the frameworks.php file (also in the includes folder) directly to change from where the configuration is loaded from

    ob_start();
    require_once JPATH_CONFIGURATION . '/configuration.php';
    ob_end_clean();
    

    Just change the require_once line to the correct path.

    Again since this is a core file it could be changed by an update. But this may also affect other parts if the config file is loaded manually in components or other parts of the cms.