Web · WordPress

How to Install WordPress in a Separate Directory

install wordpress own directoryA WordPress installation contains a lot of files and can clutter up your website’s root directory. This is especially painful if you are using shared hosting and you would like to keep the root directory of your primary domain clean. This guide shows you how to install WordPress in a separate directory instead of installing in the root directory.

  1. Install WordPress in a separate folder. i.e. If your website root is http://techzog.com/ then install WordPress in http://techzog.com/wp. Your website (WordPress installation) can now be accessed at http://techzog.com/wp
  2. Log in to your WordPress install http://techzog.com/wp/wp-admin.
  3. Go to the General panel.
  4. In the box for Site address (URL): change the address to the root directory’s URL. Example: http://techzog.com
  5. Click Save Changes. At this point, your website will not be accessible.
  6. Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress (http://techzog.com/wp in our example) directory into the root directory of your site—the latter is probably named something like www or public_html.
  7. If you have an old site or have configured permalinks in this WordPress installation then again Copy (NOT MOVE!) the .htaccess file from the WordPress directory into the root directory of your site. The .htaccess file is invisible, so you may have to set your FTP client to show hidden files. 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.
  8. Edit your root directory’s index.php. Open your root directory’s index.php file in a text editor and 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' );
  9. Save the file.
  10. Login to your site (if you aren’t still already). The URL should still be http://techzog.com/wp/wp-admin/
  11. 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.)

Note: Since the site will be down during some of these steps, it is best to make this change at a time of low activity, e.g., the middle of the night.

Source: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

You might also want to read up on How to Redirect 404 pages in WordPress and How to add a Back Button in your WordPress page.

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge