Difference between revisions of "WordPress subfolder installation"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Making home page display contents of subfolder)
Line 52: Line 52:
 
</pre>
 
</pre>
  
The '''/wp''' in '''/wp/wp-blog-header.php''' indicates the subfolder where WordPress is installed.  If you use a different subfolder name, update this code accordingly.
+
The '''/wp''' in '''/wp/wp-blog-header.php''' indicates the subfolder where WordPress is installed.  If you use a different subfolder name, change '''/wp''' to '''/subfolder-name'''.

Revision as of 16:38, 28 August 2016

This article discusses the installation of WordPress in a subfolder.

Benefit

Installing WordPress in a subfolder is useful because it reduces the risk of conflict between multiple web applications on the website.

By installing each web application in its own subfolder, you reduce the risk of conflict between applications.

WordPress in a subfolder

It is common to install WordPress is a subfolder of a web server (rather than directly in the root of the server).

You then create a document in the web server root named index.php, which serves as the home page. It contains PHP code to display the WordPress content.

You also update a setting in the WordPress control panel, telling WordPress that you want it to display in the web server root.

This example assumes that WordPress is installed in a subfolder named wp.

Example:

http://mgdp2060.x10host.com/wp/

Making home page display contents of subfolder

In the root folder of your website, create a document named index.php, and enter this PHP code:

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

Note the require statement:

require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' );

The /wp in /wp/wp-blog-header.php indicates the subfolder where WordPress is installed. If you use a different subfolder name, change /wp to /subfolder-name.