If you would like to talk about your project call (02) 4474 5861
Keeping WordPress in a Subdirectory Folder
Recently working on a client WordPress website and the decision was made to keep the installation in its own sub directory folder. This helped keep the root folder clean as there was already a large amount of other files that needed to be there.
The following is the advice taken from WordPress Codex on how best to keep the WordPress installation within its subfolder and have it function as the main website.
If you have any questions about this process you can ask them at the bottom of this article.
If you already have WordPress installed in its own folder (e.g., http://example.com/wordpress), then the steps are as follows:
- Go to the General panel in your WordPress website.
- In the box for Site address (URL): change the address to the root directory’s URL. Example: http://example.com
- 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.)
- Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress (wordpress in our example) directory into the root directory of your site—the latter is probably named something like www or public_html. The .htaccess file is invisible, so you may have to set your FTP client to show hidden files. If you are not using pretty 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.
- Edit your root directory’s index.php.
– Open your root directory’s index.php file in a text editor
– Change the line that says:
require( dirname( __FILE__ ) . ‘/wp-blog-header.php’ );
to the following, using your directory name for the WordPress core files:
require( dirname( __FILE__ ) . ‘/wordpress/wp-blog-header.php’ );
– Save the file.
- Login to your site (if you aren’t still already). The URL should still be http://example.com/wordpress/wp-admin/
- 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.)
Since the site is not working for some of these steps, it is best to make this change at a time of low activity, e.g., the middle of the night.
If you already have content in your site, see when your domain name or URLs change for how to deal with references to the old URL that will remain in the database.
One thought on “Keeping WordPress in a Subdirectory Folder”
My blog is on window server and i am not able to handle Permalinks.
Can you please help me to resolve the issue. as this is windows server .htaccess file is not working. how to use web.config file here?