Tuesday, July 12, 2011

Why installing wordpress in a subfolder is a good idea

Even after building a few Wordpress websites, I often get to a point when I am looking for directions on how to do the obviously simple stuff. One such thing is how to make sure your browser knows that the wordpress website is not in the root folder. A little digging around got me to this helpful step by step manual at www.askwpgirl.com.

“Moving” WordPress from Subdirectory to the Site’s Root Directory

1. Install WordPress as you normally would, but instead of installing it in the root directory (ie in the www or public_html directory), install it in a subdirectory in the www or public_html folder.

2. Once you’ve completed your design work, adding pages to the site, etc., login to the WordPress Dashboard. From the Settings -> General tab, set your WordPress address URL to the subdirectory you installed WordPress in (without the trailing slash). Note: This will already be displayed in the WordPress address field, so you don’t have to change it. What you do need to change is the Site address URL. Set this to your site’s root address (without the trailing slash).

3. Next, MOVE (do not copy) the index.php file that is in the WordPress application directory to the root directory. You can usually do this in an FTP application by selecting the file and choosing Move. (Do not move the index.php file in the themes folder or any other folder.) (Note: If you have a site already in the root directory, such as an old static html site, then you should backup and delete those files first.)

4. In a text or HTML editor, open the index.php file that you just moved and change the location of your wp-blog-header.php to the new location.

Example: if your WordPress installation folder is ‘mywp’, you would change:

to

5. Visit the site and click an interior page to make sure it displays correctly. If it doesn’t, you may need to update your permalinks (Settings -> Permalinks and click Save Changes). If you still cannot access your interior pages, then the .htaccess may need to be moved to the same location as the index.php file (i.e. the root directory). This is not necessary on all web hosts. Be sure to update the permalinks again after you move the .htaccess file.

Remember that your login and registration links will still be http://www.yoursite.com/mywp/wp-login.php.

Now, when people visit your site, they will see all the URLs of all the pages and posts as if you had installed WordPress in the root directory, and you will have a neat WordPress directory behind the scenes.