WordPress Tutorials

WordPress File and Directory Structure Introduction

As you know that all the core WordPress software, plugins, themes, and user uploads are stored on your WordPress site. But you may probably don’t know exactly what the WordPress file and directory structure is or how to customize it. However, having a better understanding of the way that WordPress stores files and directories is helpful for you to solve some common WordPress issues independently.

Over the course of this article, we will review the basic information of WordPress file and directory structure and how to rearrange your core WordPress file structure for combatting hacks and bolstering your site’s defenses.

About the WordPress File and Directory Structure

Typically, when you have WordPress installed correctly, you will find 3 main folders and other files in the main directory where you have uploaded files.

directory structure

As you could see in the above picture, different folder can be used for different purpose:

  • wp-admin and wp-includes folders are the core folders of WordPress and you don’t need to change anything inside them for the reason that every change make inside these folders will get replaced when you upgrade your WordPress version. So, modifying on the main core files on wp-admin and wp-includes folder is strictly prohibited.
  • wp-content folder is the most important folder for the designers and developers to understand. Everything you need to install or modify will be done inside wp-content folder. The folder also contains other sub-folders, such as plugins, themes, and uploads. The uploads folder might not be created at the time of WordPress being installed but it will be automatically created once you work with images on WordPress. Other more, all uploaded images and files cannot be stored/handled in the directory until the uploads folder is provided 777 permissions, which stands for read/write/modify permission.

Besides the above, your WordPress root directory also contains few special configuration files, including .htaccess, wp-config.php, and index.php, which refer to specific yet important settings about your WordPress domain.

  • .htaccess refers to a server configuration file that is used for managing the redirects and permalinks;
  • wp-config.php tells the WordPress the way of connecting to your database and sets few global settings for your WordPress site;
  • index.php is an index file where you load and initialize all the WordPress files when a page is requested by the users.

How to Access the WordPress Files and Directories

First, make sure you have a FTP client, with which you can connect to your WordPress server. See our tutorial of what is FTP and how to use it to transfer files for more detailed information.

Alternatively, you can accomplish it by making use of File Manager—a web based application built into cPanel dashboard of your WordPress hosting account.

Upon connecting to your WordPress site either using the File Manager or FTP, you can see the whole WordPress file and directory structure. Then you can start changing it the way you like.

Change Your WordPress File and Directory Structure

The open source nature of WordPress makes it possible for all users to look up the typical file structure of a WordPress site, and furthermore, provides hackers with a chance to know exactly where to start an attack. To prevent your WordPress from attacks, you should learn about how to customize your WordPress file and directory structure.

Step 1: Create a Backup

It is possible to break your WordPress site if you’re not familiar with the whole customization process. So, creating a backup in advance is vital for you to restore the site information when things go south.

For details on how to have a backup of your WordPress site, please check our posts:

If you find some error messages printed on the front end of your WordPress site along with some sensitive information, you will realize that now it is impossible for your files to communicate with your database, not to mention displaying your WordPress site. To get rid of that, you can choose to turn on error logging therefore all issues will be printed in a log discreetly and where only you have the permission to access.

Though the processor of reorganizing your file and directory structure takes your site offline for a few minutes, you can still keep your visitors happy while switching things up through setting up a temporary redirect (302).

Step 2: Change Your File Directory

This step requires you to move but two files away from the root directory of your WordPress site to a separated directory along with a new URL similar to www.yoursite.com/core-files/ changed from www.yoursite.com. Don’t worry that you would lose your site’s address as it will keep the way it is during the process of moving files into a new directory.

Create a new directory

There are different methods that can be used to help create a new directory in the root of your WordPress site: using SSH and the command line or through the file manager inside your control panel, etc.

Update the URL for your files

Assuming that you’re running with a single WordPress install, you should navigate to your admin dashboard, and go to the General Settings page. Find out the WordPress Address (URL) field, and then you could see the name of directory you’ve created. What you need is adding a slash to the end of your WordPress site’s address and click Save Changes at the bottom of the page.

Move your files

Firstly, go back to your file manager in cPanel, select all your files and folders and then drag and drop them into your new directory. Secondly, select your .htaccess file in the new folder and then edit the file path in the pop-up when clicking the Copy button at the top of the page to reflect the root of your install. Thirdly, click Copy File(s).

After finishing copying your .htaccess file back to its original location, you can start copying your index.php file in the same way.

Edit your index page

To make your WordPress site successfully reflect your new file path, you need to update your index.php file first. Just click on the Edit button at the top of the page when you have finished copying the file to the root of your WordPress site. If your new folder is called plugins, you need to change the file path to this: /plugins/wp-blog-header.php.

Finish up

Save all the changes and log back into your WordPress site’s dashboard. The URL you visit should include your new directory now!

Leave a Reply

Your email address will not be published. Required fields are marked *