How To Remove a Sub-folder from Your WordPress URL

If you are having trouble removing a subfolder from your WordPress URL, you are right in time for the solution to your problem.

For varying reasons we will see below, you might have installed your WordPress website in a sub-folder. Having a folder on a live production website has its own problems.

In this article, I will teach you how you can get rid of a subdirectory from your live website URL so that visitors to your website do not see the subfolder.

Before we get into how to remove that annoying word from your website link, I will need to lay some grounds so that you fully understand what we are dealing with.

Example Of A Website in a Folder.

If your website domain is www.example.com but when you visit it you get automatically redirected to www.example.com/subfolder then your WordPress installation was made in a subdirectory named subfolder.



How You Might Have Installed WordPress In A Sub-folder Called WP.

Many people install WordPress from automated installation scripts like Softaculous. The scripts provide an easy, quick and automated way of installing WordPress in just minutes for even beginners. The user does not need any technical knowledge to install WordPress.

For many new users, they will follow the proposals of Softaculous and one of them is to install WordPress in a sub-folder named “wp”. The reason why the script developer say it useful to install WordPress in a subdirectory was because he did not want to overwrite your already existing website incase it existed.

By following the proposals of Softaculous, many users end up installing WordPress in a sub-folder without actually requiring one.

If you are new to installing WordPress, Consider reading my detailed article on how to Install WordPress On Your cPanel Server or How to Install WordPress Locally on Your Computer.

Why You See /wordpress/ in Your WordPress Site URL Instead of Simply Your Domain

This is a very common situation with people who have installed WordPress manually rather than those who install it with automated scripts we discussed above.

When you download WordPress from WordPress.org, the files are placed in a compressed file normally named latest.tar.gz. After you uncompress, all the files will be in a sub-folder named “wordpress”.

If you upload and uncompress the installation file on your hosting server, you will need to move all the files from the folder named “wordpress” to the root directory before you proceed with the installation.

YOU MAY ALSO READ:   WordPress Multisite vs. Multiple Sites - Why Choose Multi Site Over Single Site

One common mistake during installation of WordPress is to leave the files in this folder and proceed with the installation of wordpress. If you do this, you will end up with the word “wordpress” in your site URL.

Why You May Need to Install WordPress in a Sub-Folder

WordPress comes with the option of installing it as a multi-site where you run several websites on a single WordPress installation. This feature has its advantages and a fair share of its problems. For more on this Read my Earlier article on WordPress Multisite vs. Multiple Sites – Why Choose Multi Site Over Single Site

If you run a website that has several independent sections but you are scared of the problems of running a multi-site, you may need to install several instances of WordPress on the same domain.

In this situation, organising your WordPress installations in sub-directories might prove a great way to keep your sites organised and help users know which installation handles what topic.

Does Installing WordPress in a Folder Affect Your SEO?

Let me put a Caveat before I answer. Holding other factors constant, installing WordPress in a folder shouldn’t affect your SEO.

Search Engines crawl your website effortlessly even if they were installed in either a subfolder or a subdomain or the main site. For more on this Read my article on – Subdomains vs. Subfolders: Which Is Better for SEO.

This video below is a confirmation from google that installing wordpress in a subdirectory will not have any effect on your SEO efforts.

Now let me remove my caveat. The length of your slug is an important aspect of your SEO efforts. Imagine you have a long domain since short ones are almost always taken. And you add that ‘wordpress” folder to your URL, before you start writing your slug you will be limited with available characters for google to reward you with some juice for a good slug. That sub-folder may not directly affect your SEO but the length of your slug will.

YOU MAY ALSO READ:   What To Consider When Choosing A WordPress Host For Your Website

How To Remove a Sub-folder from Your WordPress URL

So now that we have put all the questions out of the way, lets get the job done! Here are the different methods you can employ to remove sub-folders from your URL structure.

Method One: Re-Install WordPress.

This method is useful if you have nothing to lose in the old installation. This is best for those who may have just installed WordPress and have not yet added much content.

If you have uploaded custom content like themes and plugins, make sure you make a backup copy of those as you will need them after re-installation.

To remove your old installation, simply delete all its content and files plus associated databases. After removal, you can then reinstall a new instance of WordPress in your root directory.

If you are trying to remove a sub-folder/ wordpress / wp from a website that already has content that you do not want to lose, then use the methods below.

Method Two: Change WordPress Site Address

For purposes of this tutorial, I will be removing a folder named “wp” from my WordPress URL.

Please note that this method will not move the WordPress installation from the folder named wp. The admin area will still be located at yourdomain.com/wp/wp-admin. The media files you uploaded before and that you upload in future will also not be moved to the root. Only the public front end of your website will be moved.

The advantage of using this method is that it’s extremely easy and fast to remove that annoying folder name from your WordPress URL.

Step 1. Login to your WordPress Admin Area.

Step 2. Under Settings, go to General – Settings >> General.

Step 3. Change Site address to the root eg https://your-domain.com. Leave the “WordPress Address” unchanged and click Save.

WordPress Address vs Site Address
WordPress Address vs Site Address

Step 4. Connect to your website using FTP or your default host file manager and edit your .htaccess file.

Step 5. Make a copy of your index.php file located in wp folder and have the copy uploaded to root.

YOU MAY ALSO READ:   How to Install WordPress Locally on Your Computer.

Step 6. Edit the index.php file you uploaded in root.

Locate:

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

Change it to :

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

Step 7. Save the changes. If you are using FTP then upload to root.

Your website should now be resolving perfectly well at yourdomain.com but your admin interface is still located at yourdomain.com/wp/wp-admin

Method Three: Move WordPress to Root Directory

In the previous method, we did not move the physical files from the folder wp apart from just two files. In this method, we will permanently move all files located in wp to the root maintaining the file structure.

Step 1. Install and activate the Duplicator plugin on your website.

Step 2. Go to Duplicator » Settings page and click on the ‘Create New’ button.

Step 3. Run through the guided Duplicator wizard to create an installer package of your complete website after you click Build.

Step 4. Download the installer packages when it’s fully compiled.

Step 5. Create a New Database and Database user to be used by your new WordPress installation. Assign user all permissions.

Step 6. Upload the Duplicator archive package and the installer file you downloaded earlier to the root directory of your website.

Step 7. Visit yourdomain.com/installer.php

Step 8. When the Duplicator installer wizard opens agree to terms notice by ticking the select button. Click next to every prompt.

Duplicator wizard

Step 9. Fill in the database details of the database you created above.

Step 10. If prompted, fill in your site URL and Path. Normally this should be auto-detected.

Duplicator will now finish the migration, and you will be able to click on the Admin login button to access your website on the new location.

Bonus Step:  To help your users and search engines find your web pages much easier, set up redirects. You can install and use the Redirection plugin.

Now everything should be working very well. If you would like to do the work for you, feel free to hire one of our WordPress experts to help you for only $15. Click here to order.

Was this Helpful?

Leave a Reply

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