How to Change Directory in WordPress

When setting up a WordPress website, many users create their site in a folder named ‘wordpress’. This can lead to an awkward URL structure that includes “/wordpress/” in the web address. 

Instead of appearing as http://www.yoursite.com/, it might look like http://www.yoursite.com/wordpress/.

Over the years, numerous readers have asked how to resolve this issue. Having /wordpress/ in your website address can seem unprofessional and may confuse your visitors.

Change Directory in WordPress

Why Website Have /wordpress/ in Its URL

Installing WordPress is relatively straightforward, and most hosting providers offer one-click installers directly in their control panels. 

However, beginners who opt to install WordPress manually may accidentally place it in a subdirectory, commonly named “wordpress.” 

This mistake often occurs when users upload the entire “wordpress” folder found in the official WordPress.org download package. 

Please note that the method discussed below is intended solely for new WordPress websites, not for those that are already running.

1. Begin with a New WordPress Installation

If you have just installed WordPress and your website is empty, you should start over immediately. 

Delete the current installation and follow our WordPress installation tutorial to reinstall it correctly.

For those who have already added content to their website, there are two straightforward methods to remove “/wordpress/” from your site’s URL. We will cover these in step 2 and 3.

2. Change The WordPress Site Address

If you have an established WordPress site, you must know that this method is not only easier but also much quicker.

Keep in mind, though, that your media files, such as images, will still contain “/wordpress/” in their URLs.

First, log in to your WordPress admin area and go to Settings » General. You will see the ‘WordPress Address’ and ‘Site Address’ fields, both of which should have the same URL.

Change the ‘Site Address’ to point to your root domain (e.g., http://www.example.com), and leave the ‘WordPress Address’ as is.

Once you’ve made these changes, press the ‘Save Changes’ button to ensure your settings are updated. This step is essential for proper configuration.

General Settings

Connect to your website using an FTP client immediately. Navigate to the /wordpress/ directory and download the .htaccess and index.php files directly to your computer. If the .htaccess file is not visible, you must configure your FTP client to display hidden files.

If you are using FileZilla, press on “Server” in the menu bar and choose the “Force showing hidden files” option without hesitation.

Show Hidden Files

Once you have downloaded both files to your computer, open the index.php file in a text editor like Notepad. You will find a line that states:

Loads WP Blog Header

This line loads the wp-blog-header.php file, which is required to load your WordPress site. You must replace this existing line with the correct file path.

Enter Correct Location

Make sure to save your changes, and then upload both the index.php and .htaccess files from your desktop directly to the root directory of your domain using FTP.

The root directory, which contains the ‘wordpress‘ folder, is typically named /www/ or /public_html/.

Remote Site

That’s it! You can now access your website using the root domain, and everything should function properly.

Visit Site

However, if you need to log in to your WordPress admin, you’ll still have to navigate to the wp-admin section located inside the ‘wordpress’ directory, like this:

Move WordPress to the Root Directory

This is the most effective way to permanently move your WordPress site from a subdirectory to the root folder of your website.

Create a Duplicator Package:

Start by installing and activating the free Duplicator plugin on your website. Here we will focus on the free version, but you should seriously consider upgrading to Duplicator Pro for enhanced features like unlimited backups, scheduled backups, drag-and-drop imports, and more.

After activation, head directly to the Duplicator » Backups page and press the ‘Create New’ button.

WordPress Login

This will open the Duplicator wizard, which will efficiently create an installer package for your entire website.

Duplicator Plugin

Ensure the name of your backup is appropriate, then click the ‘Next’ button to proceed confidently.

Enter Name For Backup

The plugin will now run some scans. If everything appears to be in order, click the ‘Build’ button at the bottom.

Scan Complete

Duplicator will create a package and prompt you to download it along with the installer script. Press the ‘Download Both Files’ button to save both files to your computer.

For a Fresh WordPress Install, Create a New Database

It is possible to use your existing WordPress database; however, it is advisable to create a new one to keep your old database safe and unchanged.

This approach allows you to easily revert to your original site if any issues arise. To create a new database, log in to your hosting account’s cPanel dashboard, scroll down to the ‘Databases’ section, and press the ‘MySQL Databases’ icon.

Build Status

After that, give a name for your database.

Now, press the ‘Create Database’ button.

MySQL Databases

cPanel will now generate a new database for you. After this, scroll down to the ‘MySQL Users‘ section.

Here, give a username and password for new database user, and then press the ‘Create User’ button.

Create Database

To assign database permissions to the new user, scroll down to the “Add User to Database” section.

First, choose the user you created from the dropdown menu next to the “User” field.

Then, choose the appropriate database from the dropdown menu.

Lastly, press the “Add” button to complete the process.

Create a User

The new database has been ready to be used for the fresh WordPress installation.

Run the Duplicator Wizard

Upload the Duplicator archive package and the installer file to the root directory of your website,
where the /wordpress/ folder is located.

Add User to Database

Once you have uploaded both files, open the installer script in a browser window. You will need to enter your site’s root URL and then add /installer.php to it.

Remote Site 2

This will launch the Duplicator installer wizard.

Installer Script

Check the terms and conditions box and press ‘Next’ to proceed without delay.

You will then need to provide the database information. Enter the details for the database created

Duplicator Installer Wizard

After entering the database information, press the ‘Next‘ button to proceed. Duplicator will unpack your WordPress database backup from the archive into the new database.

You will then be prompted to update the site URL and path. Usually, you don’t need to make any adjustments, as the system will automatically detect the new URL and path. If it fails to do so, you must manually enter the details in this section.

Database Information

The duplicator has successfully completed the migration.

You can now press the ‘Admin Login‘ button to access your website at the new location.

Update Data

Set Up Subdirectory to Root Folder Redirects

Congratulations on successfully moving your WordPress site from the subdirectory to the root folder.

Now, it’s essential to set up redirects to ensure your users and search engines can locate your website at its new location.

First, connect to your WordPress site using an FTP client, and then proceed to delete the old /wordpress/ folder immediately.

Test Site

Afterward, navigate to the admin area of your WordPress site. Since you have moved it to the root directory of your website, your WordPress admin URL will look like this:

Remote Site 3

Once you activate the plugin, navigate to the Tools menu and choose the Redirection option. The plugin will display a setup wizard.

Simply press the ‘Continue Setup‘ button, and then press ‘Finish Setup‘ to complete the process.

Admin URL

To establish your redirect, go directly to the ‘Redirects’ tab.

First, ensure you check the ‘Regex’ box in the top corner of the first field.

Then, confidently enter https://example.com/wordpress/.* in the ‘Source URL’ field. Finally, in the ‘Target URL’ field, enter https://example.com/$1.

Basic Setup

Replace ‘example.com’ with your own domain name immediately. Then, press the ‘Add Redirect‘ button to save your changes.

This step is crucial because it ensures that any user trying to access your website with ‘/wordpress/’ in the URL will be automatically redirected to the correct posts using your new root URL. Take action and ensure this is done without delay.

Conclusion

In conclusion, change directory in WordPress is essential for enhancing both the professionalism and search engine optimization (SEO) of your website. By eliminating the default directory structure, your URL becomes cleaner, more user-friendly, and far easier to remember.

Furthermore, this change significantly strengthens your security by making it more challenging for potential attackers to identify your site’s content management system (CMS). Take this critical step to improve your site’s performance and security.

Comments

Leave a Reply

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