Archive

Archive for November, 2004

Search Engine Optimization (SEO) for phpBB URLs

November 20th, 2004 No comments

I recently installed phpBB on HappyMudan.com, a new site my wife and I launched last week. I like phpBB, but it’s not the most search engine friendly bulletin board. I did a little Googling and found this site, which has a few optimization tips and which I highly recommend.

However, one thing it doesn’t include is tips on how to rewrite your urls into more meaningful names. As an example, it’s usually a good idea to have the title of a page in the name of the url because search engines give those keywords more weight. So, for example, we’d like the url http://www.happymudan.com/discuss/viewforum.php?f=4 (which looks pretty meaningless) to be something relevant to the keyword “immigration,” which is the topic for this forum. After a little hacking, I was able to come up with a url of the form http://www.happymudan.com/discuss/forum-Immigration-id_4.html. It’s not perfect, but it’s a lot more meaningful than before.

Fortunately, there are only a couple of places where these kinds of urls are really necessary – the listing of forums and the listing of topics.

As an example, if you have two forums – “derek’s news” and “funny jokes” – you want the urls to be something like:

/derek’s-news.html
/funny-jokes.html

Since phpBB processing all happens in the same directory, we have to add some hints to the urls to tell Apache which script to pass them to. So alter those urls to something like:

/forum-derek’s-news.html
/forum-funny-jokes.html

Further muddying the waters, phpBB allows two different forums to have the exact same name (ditto with topics). So we have to also put the unique forum ID into the url:

/forum-derek’s-news-id_93.html
/forum-funny-jokes-id_234.html

Lastly, forum and post names can have non-standard url characters in them (such as ‘ and &). So we have to urlencode them:

/forum-derek%27s-news-id_93.html
/forum-funny-jokes-id_234.html [no change on this one]

So, how do we do this? It’s actually pretty simple. There are two files to edit.

The first is index.php in the root of your installation. Search for:

$template->assign_block_vars(’catrow.forumrow’

Immediately above this code block, add the following:

//derek’s seo url hack
//use the forum name as part of the url
$forum_name=$forum_data[$j][’forum_name’];
$view_forum_url=trim($forum_name);
//prepend ‘forum’ so we know this url is for viewforum.php
$view_forum_url=’forum-’ . $view_forum_url;
//replace spaces with dashes
$view_forum_url=str_replace(’ ‘,’-’,$view_forum_url);
//replace “/” with dashes – for some reason my (admittedly weak) Apache regex doesn’t like “/”
$view_forum_url=str_replace(’/’,’-’,$view_forum_url);
//append -id_ as a handle for the regex to find the correct forum_id
$view_forum_url = (urlencode($$view_forum_url).”-id_$forum_id”;
//add .html to make it look like a static web page
$view_forum_url .=’.html’;
$view_forum_url=append_sid($view_forum_url);

A few lines below the $template->assign_block_vars section, you should see this:

‘U_VIEWFORUM’ => append_sid(”viewforum.$phpEx?” . POST_FORUM_URL . “=$forum_id”))

Comment this out and replace it with:

‘U_VIEWFORUM’ => $view_forum_url)

Save the file.

Next, open the file viewforum.php. Search for “$view_topic_url = ” without the outer quotes.

Comment out this line using //. Immediately above this code block, add the following lines:

//derek’s seo hack
//use the topic title as part of the url
$view_topic_url=trim($topic_title);
//prepend ‘topic’ so we know this url is for viewtopic.php
$view_topic_url=’topic-’ . $view_topic_url;
//replace spaces with dashes
$view_topic_url=str_replace(’ ‘,’-’,$view_topic_url);
//replace “/” with dashes – for some reason my (admittedly weak) Apache regex doesn’t like “/”
$view_topic_url=str_replace(’/’,’-’,$view_topic_url);
//append -id_ as a handle for the regex to find the correct forum_id
$view_topic_url = urlencode($view_topic_url).”-id_$topic_id”;
//add .html to make it look like a static web page
$view_topic_url .=’.html’;
$view_topic_url=append_sid($view_topic_url);

Save the file. We’re almost done.

Add the lines below to your .htaccess. NOTE: this code assumes your phpBB is in a subdirectory called phpBB. Change the “phpBB” to whatever directory you use, or remove it altogether if phpBB is in your document root:

RewriteEngine On
RewriteRule ^/phpBB/topic-(.*)-id_([0-9]*).html /phpBB/viewtopic.php?t=$2 [QSA]
RewriteRule ^/phpBB/forum-(.*)-id_([0-9]*).html /phpBB/viewforum.php?f=$2 [QSA]

QED, no? At least so far. I hacked this out in a hurry and I suspect the regex is not robust enough for all situations. Let me know if you have problems or improvements and I’ll update them here.

Update: I haven’t tried it yet, but a friend pointed me to this mod for phpBB.

World’s Greatest FTP Client

November 15th, 2004 No comments

Leo Notenboom recently turned me on to WebDrive, and I love love love it. In a nutshell, it allows you to mount an FTP site as a hard drive, so your applications treat it just like any other hard drive. It’s very handy when editing HTML. Just open the file from the remote computer, edit and save just as you would for a local file. Now I do most of my editing directly on the remote machine, then synch them up to my local computer (mostly for backup purposes) using InSynch.

Categories: Technology Tags:

New Discussion Site for Chinese Expats and Cross Cultural Relationships

November 15th, 2004 No comments

My wife Dong, who runs HappyMudan, is from China. I’ve always been interested in travelling to and understanding other cultures, so she’s indulged my interest in spades just by answering my stupid questions (”Do they have Christmas in China? What’s a typical Chinese breakfast? Are there pizza parlors in China?”)

Anyway, one shared interest we have is in doing business with and perhaps in China. (We’d like to live there for a few years.) Recently, while researching what became HappyMudan, we began talking with her cousin Xi in Beijing. Xi is a bright young man of 21 who wants to start a business. He’s interested in doing something over the Internet, so we’ve been helping him get started. He still hasn’t decided on the exact business model, but he wants to do something with Google AdWords.

Google is fairly popular in China, but it’s not the dominant force it is here. There, Baidu is the #1 search engine. In contrast to the US, where seemingly every search results in a ton of AdWords ads, Google China is almost virgin territory.

Why am I writing this? Posterity. We belive China is poised for explosive growth on the Internet. I want to document the experiments we do there and perhaps help others see the way.

So, to wrap this up, here are a few pros & cons to consider about China.

Pros

  • Over a billion people live there! Actually, that number is misleading. It’s better to think of China as a series of smaller markets in the major urban centers – Beijing, Shanghai, Hong Kong etc – encompassing perhaps 100 million people
  • Gigantic manufacturing capacity. It seems like everything – everything – is made in China. Much of it is exported to the West, of course, but the Chinese middle class is growing, as evidence by the emergence of Christmas as a major gift-giving holiday. (Remember when I asked about that before?) They don’t celebrate the Christian aspect of Christmas, just the naked capitalism of it.
  • China is 2-3 years behind the US on the Internet. This is a good thing for entrepreneurs. It’s hard to believe, but AdWords is less than three years old. During that time Google has grown into a billion dollar company, and a lot of other companies are making money on its strong back. Most Chinese companies have not discovered how powerful search engine marketing is yet. Given that it’s only the most important development in the history of direct marketing, there’s a lot of money to be made showing Chinese companies how to use it.

Cons

  • Credit cards not as popular. This is a biggie. Credit cards are gaining in popularity in China, but the penetration rate is very low. The idea of buying product over the Internet in China is still very foreign.
  • Piracy is still a big problem. Another biggie. Chinese companies rip off everything from DVDs to Calvin Klein logos. Given the chance, they’ll probably rip off e-books and software too.
  • The Chinese currency is undervalued. Part of the reason Chinese goods are so cheap is that the government of China keeps the currency artificially low relative to the dollar. For US consumers, this means great prices. For US investors, it means more bang for your investment buck. But for companies selling products in China, it could be a disaster. For example, a book that costs $20 in the US may sell for as little as $2 in China. How can you make a profit on that?
Categories: China Tags:

Search Engine Optimization (SEO) with WordPress

November 15th, 2004 No comments

WordPress is a great blogging tool, no doubt about it. (It powers this blog.) What you may not know is that it has some great features for search engine optimization (aka SEO). Here are a few tips on getting the most out of WordPress for SEO.

Optimize the Template

As it happens, the default WordPress template is pretty search engine friendly. In particular, it uses Cascading Style Sheets for positioning, which means there isn’t a lot of crufty <table> markup to bloat your html. However, I would recommend one change to the “out of the box” template: change the title of posts to <h1> instead of <h3>. Why? Because Google places higher emphasis on content that is inside of <h1> tags. If your titles are keyword rich (they should be – look at the title of this post for an example), making this change elevates the post’s importance oh-so-slightly in Google’s eyes.

Making the change is simple. Login to WordPress and click on the “Templates” menu item. Open the index.php file (the default), and search for <h3 class=”storytitle”. Change h3 to h1. Click “Update File” and you’re all set.

Optimize the File Name for Your Post

For added Google mojo, you want the title of your post (which is keyword-rich, remember) to also be the name of the file. When Google sees your keywords in the name of the file, it assumes those keywords must be important. Why else would you name it that way?

By default, WordPress uses query strings for the names of your files, so a post’s URL will look something like http://www.yoursite.com/index.php?page=123. Looking at this, you can’t guess what the post is about, can you? Wouldn’t it be better if it were something like http://www.yoursite.com/search-engine-optimization.html? Google thinks so too.

Happily, it’s pretty easy to configure WordPress do this for you automatically.

First, you need to configure WordPress to show you the “post slug,” which is WordPress’s term for the file name. As an example, the post slug for this post is “search-engine-optimization-seo-with-wordpress.” To do this, click on the Options menu, then click on the “Writing” submenu. Next to “When starting a post, show:” select “Advanced Controls.” Save your changes by clicking the “Update Options” button.

Next you need to configure the permalink structure. The permalink is the link the WordPress generates for a specifc post. For example, the permalink for this post is http://www.askderekscruggs.com/search-engine-optimization-seo-with-wordpress.html. To do this, click again on the Options menu, then on the Permalinks submenu. Scroll down the first text box and enter the following:

%postname%.php

This tells WordPress to use the name of your post in the permalink and add “.php” to the end of it.

Click the button labelled “Update Permalink Structure.” Once it’s done updating, at the bottom of the page you will see a new text box with abunch of code in it that looks something like this:

RewriteEngine On
RewriteBase /
RewriteRule ^categories/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?category_name=$1&feed=$2 [QSA]
RewriteRule ^categories/?(.*) /index.php?category_name=$1 [QSA]
RewriteRule ^author/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?author_name=$1&feed=$2 [QSA]
RewriteRule ^author/?(.*) /index.php?author_name=$1 [QSA]
RewriteRule ^([_0-9a-z-]+).html([0-9]+)?/?$ /index.php?name=$1&page=$2 [QSA]
RewriteRule ^([_0-9a-z-]+).html/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?name=$1&feed=$2 [QSA]
RewriteRule ^([_0-9a-z-]+).html/trackback/?$ /wp-trackback.php?name=$1 [QSA]
RewriteRule ^feed/?([_0-9a-z-]+)?/?$ /wp-feed.php?feed=$1 [QSA]
RewriteRule ^comments/feed/?([_0-9a-z-]+)?/?$ /wp-feed.php?feed=$1&withcomments=1 [QSA]

This is code for Apache’s mod_rewrite functions. Basically, this tells your Apache web server to transform (using the example above) http://www.yoursite.com/search-engine-optimization.html into the format that WordPress understands: http://www.yoursite.com/index.php?page=123

If that seems confusing to you, don’t worry about it. The main thing to know is that you need to copy and paste this text into a text file, name it .htaccess (yes, that’s a period at the beginning of the file name) and place that file in the same directory as your WordPress installation. Assuming you followed these instruction correctly, the changes should take place immediately. Simply navigate to your blog page and click on the permalink to verify that it works. QED, no?

Doing these two things alone will do wonders for your search engine traffic. Give them a try and let me know what you think.