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

Websavers Inc

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

Caveats:

  1. 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.
  2. Having a different WordPress Address from Site Address can cause some plugins and themes to stop working. It’ strongly recommended to clone the site to the root rather than leave it in a subfolder.

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.

WARNING: At step 7 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

  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.

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!

Posted in ,

Jordan Schelew

Jordan has been working with computers, security, and network systems since the 90s and is a managing partner at Websavers Inc. As a founder of the company, he's been in the web tech space for over 15 years.
WS-Logo-only-image-large

About Websavers

Websavers provides web services like Canadian WordPress Hosting and VPS Hosting to customers all over the globe, from hometown Halifax, CA to Auckland, NZ.

If this article helped you, our web services surely will as well! We might just be the perfect fit for you.

24 Comments

  1. Geoffrey on March 16, 2021 at 7:32 pm

    Hi Jordan,
    I saw this method a couple of times already.
    My WP is installed at domain/wp/ and was completely build there.
    I renamed the site url to domain (without /wp/), seems to be working fine when consulting the website.
    But I am getting an issue with featured images and linking parents when I open to edit the pages.
    Also when I try to add images to the page, I cannot save it anymore.
    Any thoughts on this issue?
    Thanks!

    • Jordan Schelew on April 21, 2021 at 7:20 pm

      Hey Geoffrey,

      I’d suggest looking into the wp media upload path — perhaps it’s conflicting 🙂

  2. Mike Kirboy on May 24, 2020 at 5:59 am

    Nope, doesn’t work, none of it works.

    Somehow my wordpress is displaying in a folder called “blog”. This folder does not exist on my webserver, I searched the whole hard drive from the command line and there is no folder called “blog”.

    I updated the “Site address” to remove “blog” and the site appears without typing “/blog”, but I still can only access my wp-admin at “/blog/wp-aadmin”. Honestly, I am starting to hate wordpress; I don’t want a folder called “/blog” even if it’s just for my wp-admin. I want it to do what I want, not what it wants.

    I tried removing “/blog” from both URL fields, and it broke everything.

    • Jordan Schelew on May 25, 2020 at 10:33 am

      Hey Mike,

      This guide will definitely only work if the site really does exist in a subfolder but you don’t want it to appear to be. In your case it’s kinda the opposite where it doesn’t exist in a subfolder, but it’s showing like it is.
      > I tried removing “/blog” from both URL fields, and it broke everything.

      That is the solution. After you make that change, check your server logs to determine what it broke and fix that specifically. You might have to repeat that a few times. If your hosting is with us, this kind of issue shouldn’t occur. Perhaps it’s time to consider a switch!

  3. Eddie on February 18, 2019 at 5:08 pm

    Hi there,

    i overlooked your warning:
    ” 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”

    Now i can’t log in in the backend. How can i get back in to my wp-dashboard again :S?

    • Allen Pooley on February 18, 2019 at 5:13 pm

      Hey Eddie,

      There’s two ways to do this:
      One would be to edit the wp_options table in the DB, find the field for the WP URL, and change it there. Your host should give you access to PhpMyAdmin or something similar to do this.
      Somewhat less terrifying; because, lets face it, DBs are terrifying; would be to add the following to your wp-config.php file:


      define('WP_SITEURL', 'https://yourdomain.tld');
      define('WP_HOME', 'https://yourdomain.tld/subfolder');

      Of course replacing yourdomain.tld and subfolder with the proper domain and folder 🙂

      Cheers
      Allen

      • Eddie on February 18, 2019 at 5:20 pm

        Hi there,

        i did try to edit the wp-config, but then the login didn’t work somehow. Now i’ve moved all wp folders/files to the root, logged in and changed it back.

        But it shows a blank page – where it should show the coming soon page. Could it be the coming soon is confused now? (i know i am 😉 )

        Peace, Ed’

        • Eddie on February 19, 2019 at 5:03 am

          Add. I just noticed there was still an empty index.html in the httpdocs folder overruling the index.php…removed the index.html and all works fine.

          Thanks for the post. Cheers1

      • Felix on May 18, 2021 at 3:03 am

        Hey,

        this did not work for me unfortunately. I did the same mistake eddy described above.
        I get an HTTP ERROR 500 when visting the /wp-admin URL
        The subfolder URL does show a non reactive page of. the menu

        Is there another way to get my structure back?

        Best, and thanks for help!

        Felix

  4. 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 /wordpress/page-name/ redirects correctly to: /page-name/
    However, the link /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

  5. 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.

  6. 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.

  7. 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' );

  8. 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