Skip to main content
How To...SEO

HOW TO: Serve WordPress from a subdirectory (no .htaccess)

This is not a proxy method – rather we’ll be “physically” serving WordPress from /NEWS/ in the web root – without relying on .htaccess (FPM-compatible)

For the purposes of this guide, we’ll use DOMAIN.COM/ as the root of your public web directory (ie. public_html) and we’ll use DOMAIN.COM/NEWS/ as the desired subdirectory.

STEP 1: Make the new folder and move everything exceptindex.php into it (where news is the new subfolder):

mkdir news && mv -r !(index.php|news) news/

STEP 2: Edit the last line in the remaining index.php in root to map the subfolder path:

 * 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__ ) . '/news/wp-blog-header.php' );

STEP 3: In the subfolder, set the HOME and SITEURL in wp-config.php to match the new path (just above That's It. Pencils down):

// Subdirectory WordPress Path Address
define('WP_SITEURL', '');
define('WP_HOME', '' );

# That's It. Pencils down

STEP 4: Perform a search-replace with your method of choice, targetting any existing wp-content references. Here’s what it looks like with WP CLI:

wp search-replace "" "" --precise --all-tables --skip-tables=GUID

STEP 5: Flush your permalinks. You can do this by either logging into wp-admin, navigating to Settings, Permalinks and simply clicking Save or by using this WP CLI command:

wp rewrites flush