WordPress: Doing Root the Right Way.

I’m going to try to keep this brief as I am not a big WordPress hacker.  For the most part WP just works and allows me to get on with what I really want to do which is write and interact.  When I first started StaticNAT.com I had all sorts of crazy ideas and to this day I still do.  But back then I had not clue how to really setup a blog, I just dove in and hoped for the best.  Well it turns out what how I did it is really not all that bad but I had just not configured everything in a way that was optimal.  So here is what I did.

On the Initial WordPress install I told the installer to use /staticant.com/WP/ as the directory for all my wordpress install files.  That is all well and good but I ended up having to go to www.staticnat.com/wp to get to my blog, and that was not so good.  The quick and dirty fix was to use an index.html file that looked just like this:

< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">StaticNAT


The problem was that it just ended up pointing back to http://test.staticnat.com and quite honestly thats ugly. As I have been cleaning up the site in preparation for all the cool new things we are adding I decided I needed to make a change even if it was painful. My plan was to backup my WP data and DB then create a new install of WP at /statincat.com/ the root directory for this site. After that was all done I would import all the old data re-install all my plugins re-create the Admin users and move on. But I was a bit concerned about how clean this would be especially from and SEO perspective.

Digging a bit I found out that the way I deployed five years ago was really not wrong and that WP had provisions already to live in a unique director but still present itself without the index.html file. So off I went to find out how to do it. What I found was this support forum post on DreamHosts site. This was convenient since Dreamhost is my web host so I was sure it would work out well.

To sum it all up for you what you have to do is go to Settings –> General –> and change the Site Address (URL) to http://www.staticnat.com. Once you have done that you have to create a .htaccess file and place it in both the /staticnat.com/WP and /staticnat.com/ folders. I did not like all of the things that were in the .htaaccess file that was shown in this forum article so I modified it to look like this;

# protect the htaccess file

order allow,deny
deny from all

# disable the server signature
ServerSignature Off

# limit file uploads to 10mb
LimitRequestBody 10240000

# protect wpconfig.php

order allow,deny
deny from all

#who has access who doesnt
order allow,deny
#deny from 000.000.000.000
allow from all

#custom error docs
ErrorDocument 404 /notfound.php
ErrorDocument 403 /forbidden.php
ErrorDocument 500 /error.php

# disable directory browsing
Options All -Indexes

# set the canonical url
RewriteEngine On
RewriteCond %{HTTP_HOST} ^staticnat.com$ [NC]
RewriteRule ^(.*)$ http://www.staticnat.com/$1 [R=301,L]

# BEGIN WordPress

# END WordPress

Then you have to copy the index.php files from /staticnat.com/WP to /staticnat.com/. That should be all there is to it. But for me it was not. I ended up having to go into the index.php files and change the following:

/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');

TO

/** Loads the WordPress Environment and Template */
require('./WP/wp-blog-header.php');

That did it. I have a few custom links that are not working following the change but thats minor and should be resolved pretty quick. Keep in mind if you end up using this any of the references to www.staticnat.com should be replace with your domain name for it to work for you.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.