How to change your WordPress URL when installed in a subfolder

- by

Oftentimes people install WordPress in a subdirectory of the main website. One-click installers like to do this. Say your domain is, but WordPress lives in By default this means that people will have to visit your website at the latter URL.

But what if you want your URL to be, without that /wordpress at the end?

No problem I say – let me talk you through it. It may sound scary, but that’s just because we have to do some tweaks to files we don’t normally touch.

You have to do three things:

  • change database values and tell WordPress it shall present itself somewhere else
  • add a tweaked version of index.php to your root directory
  • add some statements to your .htaccess file

Have your favourite text editor and FTP client ready and let’s get started!

Change Database Values for site and home

Login to your site and head over to Settings – General. You should see two URL fields there which by default contain the same value:

Screen Shot 2013-10-12 at 11.37.54

The first URL is where WordPress physically lives on the server. The second URL is what’s displayed in a visitor’s browser. In our case, we want to change the second URL to, like so:

Screen Shot 2013-10-12 at 11.38.16

Hit save and you’re done in the admin area. Note that doing so means you will lose access to your site for a moment! Don’t panic though, because we’re about to fix that next.

Tweaking index.php

The index.php file is a default file that browsers look for when you point them at a directory. If that file is there it is loaded automatically and will be executed. If it’s not, the browser will look for similar files, such as

  • start.htm / start.html
  • index.htm / index.html

In our example, when we navigate to it is likely that there’s nothing there, or perhaps one of the files mentioned above from a default or previous installation. Make sure all those are deleted in the root, so that the one we’re about to create (index.php) is the only such file in the root directory. If you leave any of the other standard browser files, you can’t really guarantee which one is loaded – and we want to make sure index.php is the only one that’s there.

We need a copy of the index.php file that’s inside your WordPress installation (for us it’s Download it with your favourite FTP client, then edit it with your favourite ext editor. You’ll see something like this:

 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 * @package WordPress

 * Tells WordPress to load the WordPress theme and output it.
 * @var bool
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */

See that very last line? That’s the one that kicks off WordPress. It’s saying “load a file in this folder”. And that would work great if WordPress would live in this current folder. However, we want to tell it that it needs to load a file from the /wordpress folder.

Change that last line to point at the folder in which WordPress lives. Amend this to match your WordPress directory:


Now save the file and upload it to your root directory. Don’t overwrite the original file inside your /wordpress folder – it needs to stay there. We need to put the file so that it can be accessed at

Tweaking .htaccess

If you’re not using Pretty Permalinks your site is probably operational already ( as opposed to

The .htaccess file is a configuration file for your remote web server. It’s the service that returns websites when a browser requests it. We need to tell it that when the browser is asking it to serve up, that really it needs to serve up

This is done with something called a mod_rewrite rule. Don’t worry if this sounds weird, it’s not something you use everyday. It’s the same engine that makes it possible to have those nicely formatted Permalinks.

.htaccess is a hidden file, so make sure you tell your favourite FTP client that you want to see hidden files – otherwise you may not find it. Also, if you’re not using Permalinks you may not have a .htaccess file – in which case, just create an empty file.

Download your .htaccess file and add the following at the end:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(/)?$ wordpress [L]

Replace “” with your own domain, and “wordpress” with your actual WordPress subfolder. Save the file and upload it to the root directory of your site (leaving the one inside your WordPress folder untouched, just like we did with the index.php file).

Now head over to your personal and see your site working fine, just like it was installed in the root folder. When you login, you’ll still have to do so via as you did before.

My head hurts… can you do this for me?

No problem – book a half hour support slot here and I can do all this scary stuff for you.

Further Reading:

If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

2 thoughts on “How to change your WordPress URL when installed in a subfolder”

  1. Hi there ! Quick qestion, If I have contributors that dont have acces to admin but login from frontend ..would their logins work from the login form on frontend if I implement the above?

  2. I would assume so, yes – I guess it depends on how they log in from the front end. Usually all plugins I know hook into the same mechanism, and they all use what WordPress uses.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.