Stylehack

Wordpress Tips :: Installing WP beneath the root of your domain

Filed under:
Need some extra help installing Wordpress in a directory beneath public_html? Not sure what changes will be needed? Here’s a bit of additional info building on the official Wordpress tips to get you started. A typical Wordprress (WP) install assumes that you want to keep all the WP files in the root:
. public_html    . wp-contents    . wp-admin    index.php    wp-layout.css    wp-config.php
[These are not all the files and directories, just an example.] I wanted to keep it cleaner, as in all the WP stuff in it’s own directory… you never know when you’ll want to add something else or fiddle things a bit. But I still wanted the blog to be displayed when someone typed in www.stylehack.com, instead of www.stylehack.com/path/to/wordpress; in other words I wanted a Wordpress directory:
. public_html    . wordpress       . wp-contents       . wp-admin      index.php      wp-layout.css      wp-config.php
Ok, so what to do? Fiddle a bit! Solution, as supplied by the Wordpress Installation notes and repeated here so it’s easy to find: 1. Install and configure WP to run under the public_html/wordpress directory, then make a copy of index.php and place it in the root (public_html). Edit that copy and change the REQUIRE statement at the top of the file to include the Wordpress directory:
3a10 <  require('./wp-blog-header.php');
3a10 >  require('./wordpress/wp-blog-header.php');
[Note: 3a10 means Line 3 at character 10; < means 'was' and > means 'becomes'. All lines/characters are approx because you may have done something else with your files.] 2. Correct the path to your stylesheets:
15a68 < @import url( <?php echo get_settings('siteurl'); ?>/wp-layout.css );
15a68 > @import url( <?php echo get_settings('siteurl'); ?>/wordpress/wp-layout.css );
Repeat for any alternate stylesheets. 3. You need to duplicate your favicon in both the root and the Wordpress directory if you want it to show up consistently. 4. You end up with this structure:
. public_html   index.php   favicon.ico    . wordpress       . wp-contents       . wp-admin     index.php     favicon.ico     wp-layout.css     wp-config.php
Final thought: It’s also possible to use htaccess and rewrite directives to redirect things, but that would require more work on my part and I’m too lazy to do it that way… at least at this point in the development of Stylehack. Next installment: Understanding my-hacks.php

Stylehack © 2008 - Becky Peters :: All Rights Reserved
Powered by WordPress