How to make WordPress not appear like it’s in a subfolder

This article shows you how to ensure visitors reaching your website will see your WordPress website when it’s installed to a subdirectory like /wordpress or /blog. If you’re looking for information no how to install WordPress, we’ve got a great detailed guide for creating a WordPress blog right here!

If you’ve installed WordPress to a subdirectory like /blog or /wordpress, that means it must be accessed by going to yourdomain.com/blog or yourdomain.com/wordpress. But now you want your WordPress website to be shown to visitors without having to put in /blog or /wordpress after your domain! There’s a couple ways to do this…

Solution 1: Move WordPress to the root (Clone)

The cleanest way to resolve this is to use our 1-click web apps utility to clone WordPress into the root, then remove the original installation (the one in the subfolder). If you prefer the folder structure remain as it is (perhaps you like a clean web root!) then skip on down to Solution 2 below. If you’re indifferent, then we suggest implementing this solution:

  1. Login to Plesk
  2. Click the 1-click web apps button
  3. Find your WordPress installation in the list of installed apps, then click the button that says Clone when you hover over it. It looks like two side-by-side arrows pointing downward.
  4. Select the same domain as the destination and be sure to specify no path / subdirectory
  5. Proceed with the clone process.
  6. Once completed, check to be sure you can load your website without the subdirectory.

You’ll now see two installations of WordPress in the 1-click web apps list of installed applications. Run a backup of the old installation (in the subdirectory) then remove it by clicking the X button.

It’s important to remove the old installation for security reasons as well as to be sure that there’s nothing still relying upon the files in the subdirectory. Better to know now than it is to be unsure why there’s issues months from now!

Solution 2: Load WordPress from the subfolder

Note: do not leave multiple copies of the same site running at the same time unless they are entirely separate (different subdomains, for example). Doing so will only make things really really confusing and 1-click web apps will more than likely cause problems with this set-up during updates. Be sure that if you use this solution, it is only in the case where you’ve got a singular WordPress installation.

The following steps will show you how to set up WordPress so that it can be accessed at www.domain.com (without the subdirectory) without cloning WordPress to the root of your domain, thus allowing you to leave it in its current subfolder.

When you’re working with your primary domain’s web files (whether using the Plesk File Manager or FTP), the ‘root’ or ‘web root’ is everything within the folder called httpdocs. If this is an add-on domain, then the web root was defined by you when you initially created it — most likely it’s a folder with the same name as the domain. We’ll be referring to your webroot as “httpdocs” below, so if you’re using an add-on domain, be sure to replace that reference with your actual web root folder.

  1. If you know your FTP login details, login via SFTP or FTPS. If not, it’s simpler to use the Plesk File Manager. This is done by logging in to Plesk, then clicking on “Files” in the main menu.
  2. Open the httpdocs folder, then proceed to the folder to which you installed WordPress (probably something like /blog or /wordpress)
  3. Copy the index.php file to the parent directory (back one, to httpdocs).
  4. Edit the index.php that you moved to the web root and change the line that says require(‘./wp-blog-header.php’); to require(‘./wordpress/wp-blog-header.php’); If you used something other than “wordpress” as your subfolder installation directory/path (like ‘blog’), then place that folder name between the slashes instead
  5. Be sure to save index.php in httpdocs
  6. Login to WordPress with your administrator user and go to Settings > General
  7. Remove the /wordpress (or /blog or whatever your installation folder is) from the end of “Site address (URL)” and Save Changes.
WARNING: Do NOT change the WordPress address (URL) setting. That setting MUST continue to have the full install path. Be sure to only change the “Site address” value

Congratulations! You should now find your WordPress install is accessible at http://yourdomain.com

Did you find this guide helpful, or do you need more help? Check out our fix my website product, shared web hosting, and Canadian VPS hosting, or just check out our blog for more great information like this!

Jordan is a computer, security, and network systems expert and a lover of all things web and tech. Jordan consults with project management for software companies. Jordan is a founder and managing partner at Websavers Inc.

13 Comments

  1. Ishai on July 23, 2018 at 11:18 am

    Hi Jordan, great solution, thank you very much!

    However, I have one problem: I applied this solution on a live and running website, and it caused some of the links to break and to lead to a 404 not found page. Some of them redirect correctly, and some are not, and I couldn’t find a pattern.
    For example:
    the link http://example.com/wordpress/page-name/ redirects correctly to: http://example.com/page-name/
    However, the link http://example.com/wordpress/other-page/ does not redirect and shows a 404 error page.

    Is there a fix to it, or do I have to change manually all the /wordpress/ links?

    Cheers
    Ishai

  2. John Debeer on January 31, 2018 at 11:20 am

    Hello Richard.
    My root directory has the home page file “index.php”. Moving the WP index.php from the subdirectory to the root would override the home page file. What’s the fix? Rename WP file?
    Thanks
    John

    • Allen Pooley on January 31, 2018 at 11:28 am

      Hey John,

      Interesting use case. Typically this is where someone has installed WordPress in a subdirectory which they want to become the main directory. In your case, it sounds like you have an existing website, and you want WordPress to work within that website?

      Can you explain how exactly it’s laid out? If you’d rather discuss this in a private conversation, feel free to open a ticket/send us a message at https://websavers.ca/contact

      Cheers,
      Allen

    • sagar on May 4, 2018 at 11:18 pm

      Dear Jordan Schelew could you provide youtube or any video for this it may be helpful, please I need help
      i want to change subfolder to root directory

      • Jordan Schelew on July 26, 2018 at 11:03 pm

        Hey Sagar, I’m afraid due to regular changes in the UI, a video is often rendered outdated within just months; making keeping on top of replacing the videos quite challenging as compared to text updates.

  3. Charles Brooks on December 20, 2017 at 9:37 pm

    I followed step 2. I have my site setting in a sub folder of thecubden. I can not get it to open the front page from http://www.thecubden.org. It wantes to go to http://www.thecubden.org\thecubden and give me a 404

    • Jordan Schelew on December 28, 2017 at 3:55 pm

      Hi Charles, it looks like you used the wrong type of slash. Make sure these are forward slashes, not backslashes.

  4. Erik Lee on May 14, 2017 at 9:19 am

    i think the new index.php is
    require( dirname( __FILE__ ) . ‘/wp-blog-header.php’ );

    so where do we insert the ‘mysubfolder’ in the above line?

    • Jordan Schelew on May 14, 2017 at 9:26 am

      Hey Erik,

      dirname(__FILE__) simply means the current directory of index.php, so you’d do: require( dirname( __FILE__ ) . '/mysubfolder/wp-blog-header.php' );

  5. Richard Browning on May 6, 2017 at 7:35 am

    Thank you Jordan,

    I used your Method 2 and it worked well for me, unlike several other different methods that I saw on other websites.

    In my case, there was a file called “default.htm” in the root directory, which was there as part of a new hosting account. I renamed that to “default-old.com”, and my WordPress site looked like it was installed in the root directory, as desired.

    • Jordan Schelew on May 6, 2017 at 6:37 pm

      Hey Richard; that’s great to hear! And yes that’s a great addition in that index file extension order of processing could definitely also be problematic after getting the index.php file in place. Thanks!

Leave a Comment