Wp-config outside root

Hi! I migrated couple days ago from DesktopServer to Local. My first impressions are great - modern UI, faster environment and possibilities to turn off certain sites, which helps me to save some of the RAM. But DesktopServer has great features like airplane mod or blueprint installations. I know - Local also has blueprint installations, but I don’t get it how to create one when I want to have wp-config in separate folder…

In my blueprint installation, complete WP core is in separate folder called CMS, themes and uploads are in folder “assets” and plugins are in folder called “plugins” (since there is no possibility to move plugins folder to other folder). So I created my blueprint main installation and everything still works fine on that certain website, but problem is when I try to create new WP installation based on my blueprint - there is no database connection and I can’t connect to website… Is moving wp-config outside main folder unsupported in Local? In DesktopServer that works fine, without any kind of problems…

Hi @Zzzvone,

Glad to hear you’re liking Local so far!

Regarding wp-config.php, Local is hardcoded to look in app/public.

Do you know if the database is populated with data after creating the site from the Blueprint? If so, then you should be able to edit the wp-config.php file and be set.

Hi @clay
First of all - thank you for your help. Unfortunately, database is not created for new blueprint instalation, so I guess that I should move back my wp-config to root folder and create new blueprint?

Hey @Clay - I figured out!

First I created new WP installation from blueprint. After that I edited .htaccess file - first I deleted everything inside that file, and added this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
Options All -Indexes

# Protect wp-config.php
<Files wp-config.php>
    order allow,deny
    deny from all
</Files>

After that I created on root folder (public) new wp-config.php:

<?php
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
 define('ABSPATH', dirname(__FILE__) . '/');
/** Location of your WordPress configuration. */
require_once(ABSPATH . '/cms/wp-config.php');

And, finally I change default home and siteurl in original wp-config.php (in my case - in folder “cms”):

define('WP_HOME','http://NEW.WEBSITE/');
define('WP_SITEURL','http://NEW.WEBSITE/cms/');

Hope that this will help someone :slightly_smiling_face:

Best regards,
Zvonimir

3 Likes

Rock on! Glad you got it :slight_smile:

I was literally just typing a reply suggesting adding back wp-config.php and using a require like you did.

Thanks for sharing the solution and additional details!

2 Likes

Simply adding an index.php file at the root (public) with a path to where the wordpress install is worked for me. No need for the extra wp-config file or .htaccess lines. So this would be the index.php file below. The “SUBDIR” text replaced with the sub folder name where your wordpress installation is…

<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var  bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/SUBDIR/wp-blog-header.php' );
1 Like