A WordPress installation contains a lot of files and can clutter up your website’s root directory. This is especially painful if you are using shared hosting and you would like to keep the root directory of your primary domain clean. This guide shows you how to install WordPress in a separate directory instead of installing in the root directory.
- Install WordPress in a separate folder. i.e. If your website root is http://techzog.com/ then install WordPress in http://techzog.com/wp. Your website (WordPress installation) can now be accessed at http://techzog.com/wp
- Log in to your WordPress install http://techzog.com/wp/wp-admin.
- Go to the General panel.
- In the box for Site address (URL): change the address to the root directory’s URL. Example: http://techzog.com
- Click Save Changes. At this point, your website will not be accessible.
- Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress (http://techzog.com/wp in our example) directory into the root directory of your site—the latter is probably named something like www or public_html.
- If you have an old site or have configured permalinks in this WordPress installation then again Copy (NOT MOVE!) the .htaccess file from the WordPress directory into the root directory of your site. The .htaccess file is invisible, so you may have to set your FTP client to show hidden files. If you are running WordPress on a Windows (IIS) server and are using pretty permalinks, you’ll have a web.config rather than a .htaccess file in your WordPress directory.
- Edit your root directory’s index.php. Open your root directory’s index.php file in a text editor and change the line that says:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
to the following, using your directory name for the WordPress core files:
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
- Save the file.
- Login to your site (if you aren’t still already). The URL should still be http://techzog.com/wp/wp-admin/
- If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can’t write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.)
Note: Since the site will be down during some of these steps, it is best to make this change at a time of low activity, e.g., the middle of the night.
Source: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
You might also want to read up on How to Redirect 404 pages in WordPress and How to add a Back Button in your WordPress page.
If you think that you have a link that adds value to this article please contact us at techie[at]techzog[dot]com for evaluation of inclusion into the article.
Comments left solely for spamming links will be deleted. Thank you for understanding.