Giving Word Press Its Own Subdirectory

If you would prefer not to have WordPress's files cluttering up your site's root directory, or you would prefer a nonstandard location for your admin files as a security precaution, you can install WordPress in a subdirectory while keeping your site visible at the original location. For example, you can install WordPress at mydomain.com/blog but have the site appear at mydomain.com.

First, install WordPress in the subdirectory as you normally would. Then move the main index.php file and your . htaccess file from that subdirectory into the parent directory. In your example, you would install WordPress in the blog directory, then move index.php and .htaccess into the web root directory.

Open index.php in a text editor and edit the path to wp-blog-header.php. Add your subdirectory to the file path. In this example, you're installing WordPress in the blog subdirectory, so your line would read require('./blog/wp-blog-header.php'); Of course, you can replace 'blog' with anything you wish.

Now log in to the site at its new address: mydomain.com/blog/wp-admin. Go to Settings General and change your WordPress address to the new one: mydomain.com/blog. Leave the Blog address alone, and save your changes. See Figure 11-12 for an example.

WordPress address (URL) Slog address fURL>

http : / /word p re s 5 /bl ogj http://wordpress

Figure 11-12. Changing the WordPress address without changing the blog address

Once you've saved these options, you'll be logged out. You'll have to log back in at the new location (http://example.com/blog/wp-admin/).

0 0

Post a comment