A “blog.domain.com” That Works

I seem to have had some really bad luck doing what I thought would be very simple. I finally arrived at a solution that I really don’t feel is optimal, but it works and I’ll monitor it for a while and hope that it continues working. (You’ll know if something ended up changing).

Problem

I own “alpha.com” and I want to create a “blog.alpha.com” that actually pulls pages from “alpha.com/blog/” on the web server but the user should still see “blog.alpha.com” in their browser’s address bar.

How I did it with this WordPress 2.5.1 Blog

Hopefully if you look up at your address bar right now you see blog.bogojoker.com. If not, then this failed and completely ignore me! I ended up having to do three things:

  1. I Setup redirection for a subdomain. I used my hosting company’s Control Panel to create “blog.bogojoker.com” and point it to “http://bogojoker.com/blog/”. Please note this change does not start working immediately. It took a few hours for the redirection to be broadcast over DNS Name Servers. Once it did work I went to the next steps. I wouldn’t recommend going to the next steps until this starts working because I believe they depend on this!

  2. I logged into the WordPress Admin Dashboard. I went to “Settings” and put “http://blog.bogojoker.com” into both the “WordPress address” and “Blog address” fields. This put my browser into an infinite loop which I fixed in the final step.

  3. I FTP’d into my server, went to the “public_html/blog/” directory and commented out these lines from the hidden “.htaccess” file: (Note that adding a “#” to the start of the line comments that line out)

    #RewriteCond %{HTTP_HOST} ^blog.bogojoker.com$ [OR]
    #RewriteCond %{HTTP_HOST} ^www.blog.bogojoker.com$
    #RewriteRule ^(.*)$ http://bogojoker.com/blog/ [R=301,L]

Voila. That is how I did it. I ended up spending far too much time on what I considered “better” solutions that didn’t seem to work. In doing so I found out some things, but I can’t really be sure what I learned anything valuable from it.

Troubleshooting Tricks

If you end up having the same trouble, if you want to experiment on your own, or if you tried something that totally failed hopefully this can help.

At one point during the week everything crashed on me. Not only did the website not redirect properly but the direct paths weren’t working. I chalked it up to me turning the redirection (step 1 above) off. I stumbled upon a temporary solution to fix WordPress in the few hours it would take for that redirection to be reborn through DNS. It involves a little familiarity with mysql or phpMyAdmin and knowing your database schemas.

For those with phpMyAdmin access:

  1. Log into your phpMyAdmin

  2. Select the WordPress’s database. Most servers have username_wp### or the like, this you should recognize pretty easily or can find from your Control Panel

  3. Browse the “wp_options” table

  4. Modify the “siteurl” value to be the “real” path to the blog subdirectory, NOT what you want it to be but where it really is. For example “http://bogojoker.com/blog/” for me.

  5. Now log into your WordPress by manually going to your domains wp-admin page like so: “http://yourDomainHere.com/blog/wp-admin/”

  6. Go to the “settings” tab and change both urls to the url mentioned in step 4.

That should bring your website back up, albeit with the uglier URL structure. For those without phpMyAdmin access the you should have some form of access to your database, be it command line using the “mysql” command or via another graphical interface. Just try to follow the steps above as closely as possible.

I hope this helps you out a little if you want to accomplish the same thing. Even better though, come up with a better solution and let me know. I dreamed of solving this in a couple minutes and ended up spending a little over 3 hours taking a number of approaches. So I figured, what better to do but write about it!

Add a Comment

search