How to Redirect WordPress from Folder to Root Domain

move WordPress from folder to root

When you first install WordPress you are faced with the choice of where exactly to install the files. This decision to some extent will determine the web address for your WordPress site and how users find your content.

By default, I like to install WordPress in the root, such as mysite.com, rather than in a folder or subdomain. Many folks use scripts on their hosting platform to do the installation for them and make the mistake of installing WordPress in a folder, but later decide that they would rather have it in the root.

The reason I like to have WordPress in the root is that most of my sites are comprised of nothing other than WordPress, so there’s no need to put it in a folder or subdomain.

One request I get all the time is to move or point someone’s WordPress site from a subfolder to the root … it makes sense for marketing purposes primarily.

So, here are the instructions from WordPress. This approach works for me and should work for you too.

Using a pre-existing subdirectory install

If you already have WordPress installed in its own folder (i.e. http://example.com/wordpress) then the steps are as follows:

  1. Go to the General panel.
  2. In the box for Site address (URL): change the address to the root directory’s URL. Example: http://example.com
  3. Click Save Changes. (Do not worry about the error message and do not try to see your blog at this point! You will probably get a message about file not found.)
  4. Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress directory into the root directory of your site (Blog address). The .htaccess file is invisible, so you may have to set your FTP client to show hidden files. If you are not usingpretty permalinks, then you may not have a .htaccess file. If you are running WordPress on a Windows (IIS) server and are using pretty permalinks, you’ll have a web.config rather than a .htaccess file in your WordPress directory. As stated above, copy (don’t move) the index.php file to your root directory, but MOVE (DON’T COPY) the web.config file to your root directory.
  5. Open your root directory’s index.php file in a text editor
  6. Change the following and save the file. Change the line that says:
    require('./wp-blog-header.php');
    to the following, using your directory name for the WordPress core files:
    require('./wordpress/wp-blog-header.php');
  7. Login to your site. It should still be http://example.com/wordpress/wp-admin/
  8. If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can’t write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.)

You can read more here …

Please leave a comment below or on Twitter @steinarknutsen.

Thanks,
Steinar