WordPress installation in a subfolder
-
I have wordpress in a subfolder, called wp, and have Composer operating whereby all themes and plugins are located in the root folder wp-content (instead of in the wordpress installation folder).
In order for Duplicator to find all my site’s files I had to modify my wp-config.php and three files in the duplicator plugin.
/** Absolute path to the base installation directory, given this
installation is in wp subfolder. */
in wp-config.php I add:$wp_subfolder = “wp”;
if ( !defined(‘ROOTPATH’) )
define(‘ROOTPATH’, str_replace(‘wp’, ”, dirname(__FILE__)));and this as .htaccess to allow for redirects to the wordpress php files
and such (I made these modifications in duplicator class.config.php around line 61)…# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ – [L]
RewriteRule ^(wp-(admin|includes|snapshots).*) ${wp_subfolder}/$1 [L]
RewriteRule ^(.*\.php)$ ${wp_subfolder}/$1 [L]
RewriteRule . index.php [L]
# .htaccess Fix for 403 Error Infinite Loops
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} 403
RewriteRule .* – [L]
SetEnvIf Origin
“^http(s)?://(.+.)?(http://stage.mysite.co|mysite.com)$”
origin_is=$0
Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is
Header always set Access-Control-Allow-Credentials true
</IfModule>
# END WordPressin duplicator package.php
– $this->Archive->PackDir = rtrim(DUPLICATOR_WPROOTPATH, ‘/’);
+ if ( !defined(‘ROOTPATH’) )
+ {
+ $this->Archive->PackDir = rtrim(DUPLICATOR_WPROOTPATH, ‘/’);
+ } else {
+ $this->Archive->PackDir = rtrim(ROOTPATH, ‘/’);
+ }and in package.archive.php
– $rootPath = DUP_Util::SafePath(rtrim(DUPLICATOR_WPROOTPATH, ‘//’ ));
+ if ( !defined(‘ROOTPATH’) )
+ {
+ $rootPath = DUP_Util::SafePath(rtrim(DUPLICATOR_WPROOTPATH, ‘//’));
+ } else {
+ $rootPath = DUP_Util::SafePath(rtrim(ROOTPATH));
+ }
The topic ‘WordPress installation in a subfolder’ is closed to new replies.