Many people ask me whether they should install WordPress in a root directory or in a subdirectory. You can do it either way. If your website is built solely by WordPress and you are not very technical, it is better to install it in your root directory. This is also the most popular way to install WordPress.
However, the techie guys may not like it. Their argument is that it is not secure and not organized. They have a good point. So let’s see how to install WordPress in a subdirectory.
Installing WordPress in a subdirectory but having your domain name point to it as if it was installed in the root directory can be a little tricky. Though WordPress.org has an article explaining how to do it, it is hard for beginners to follow. In this blog, I’ll do my best to make it as easy as possible for you to work with.
- Step 1: Install WordPress in a subdirectory. For example, http://www.yourdomain.com/wordpress
- Step 2: Log in to your WordPress back office, go to Settings -> General.
- In the box for Site address (URL): change the address to the root directory’s URL. Example: http://yourdomain.com *** Not WordPress URL***
- 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.)
- Step 3: Log in to your Hostgator cPanel, go to the “File Manager.” You need to access the root directory of the domain you are working on. As the .htaccess file is invisible, select the checkbox to show hidden files.
- Step 4: Open the subdirectory where WordPress is installed. In my example, it is the “blog” folder. Copy (NOT MOVE!) the index.php and .htaccess files from the subdirectory into the root directory of your site.
- Step 5: Edit your root directory’s index.php.
- Open your root directory’s index.php file in Code Editor.
- Change the line that says: require('./wp-blog-header.php');
to the following using your subdirectory name where WordPress is installed. If your subdirectory is “wordpress”, then you should change this line of code to:
- Save the file.
- Log in to your site, the URL should still be http://yourdomain.com/wordpress/wp-admin/
I find this video tutorial very helpful. Hope you know how to install WordPress in a subdirectory. I will let you decide whether you want to install WordPress in a subdirectory or root directory
Latest posts by Mary Wang (see all)
- The Anatomy of an Optimized Web Page [Infographic] - April 6, 2015
- 5 Ways to Cure Internet Marketing Overwhelm - March 30, 2015
- 15 Useful Facebook Graph Search Queries to Find Your Target Audience - March 14, 2015