How to configure WordPress to create search engine friendly URLs for permalinks

Emily Robbins

August 25, 2004

WordPress's default behavior for permalinks is to create a URL that looks something like this:

http://www.yoursite.com/index.php?p=2

where p is the post id.

If you care at all about the search engines indexing your blog, and you should if you want anyone to read it :), you'll want to use a little SEO (search engine optimization) trick by having nice, neat URLs that describe your post.

In my case, I wanted my individual post archives to be in the root of my domain, as search engines like Google devalue a page the deeper it is into the site. I also wanted the link title be the posts name, so that my permalinks will look like this: http://www.yoursite.com/this-is-my-posts-title.htm

To do it:

- log into WordPress, and then click on 'Options'. Next click the sub-category under options entitled "Permalink"

- the page you're on will now describe all the fields you can use to create your permalink. I only cared about the post name so in the edit box just underneath where it says, "Use the template tags above to create a virtual site structure:" I typed the following:

/%postname%.htm

- at this point you should click the button to Update Permalink Structure.

Now you will need to modify your .htaccess file to do some mod-rewriting. Sounds hard, but WordPress makes it easy. First of all, if you don't know what it is, an .htaccess file is simply a text file that can contain instructions for the webserver. If you have an .htaccess file already, then you will need to edit it to add the code that WordPress provides for you (see below). If you don't have an .htaccess file, you'll need to create a text file using any text editor (notepad will do) that simply has the contents (again, see below) that WordPress tells you paste in. Those directions will be specific to the linking structure you choose, but if you go the route I went, then WordPress will have you add the following lines to your .htaccess file:

RewriteEngine On
RewriteBase /
RewriteRule ^category/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?category_name=$1&feed=$2 [QSA]
RewriteRule ^category/?(.*) /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-]+).htm([0-9]+)?/?$ /index.php?name=$1&page=$2 [QSA]
RewriteRule ^([_0-9a-z-]+).htm/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?name=$1&feed=$2 [QSA]
RewriteRule ^([_0-9a-z-]+).htm/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]


So now, my first WordPress post on my Tool Reviews Site can be found at http://www.toolreviews.biz/porter-cable-cffn250n-finish-brad-nailer-combo-kit.htm (btw - that post is more of a placeholder while evaluating WordPress than anything else..)


Posted by: Pam G. | August 26, 2004 08:08 PM

Thank you soooo much for this page! I've spent the past two or so weeks really studying blogware options, as I want to move away from blogger.com. While I'm quite comfortable with handcoding HTML & CSS, validating, and even customizing a few perl scripts, the blog world is new to me, in the hands-on sense. WP seemed to be a great choice, but I despised the no-information-given URLs it creates. Your page perfectly responds to that concern.

Now, if I can just get up the heart to delve into the unknown (to me) world of php and mySQL. Fortunately, my (new) host, Pair Networks, has the required software in place. I'll do some more reading about the basics, so come Labor Day weekend, I can take a huge cup of coffee, and dig in. By then, I *should* have made the final choice between b2evolution and wordpress.

I owe ya one! Thanks again.

pam


Emily Robbins

Contact

Website: http://www.emilyrobbins.com/

One-Line Bio

I'm almost 33, live in San Francisco with my amazing boyfriend Eric, my 3 cats (Marvin, Sam, and Sophie), and our turtle Eger.

Biography

Having grown up on Long Island, I fled as quickly as possible (which meant college). Went to Middlebury College in Vermont - (class of 93, BA in Mathematics). Loved it there, but felt the need for city living without the rush rush rush of NYC, and my love of computers and mild weather landed me in San Francisco (moved here without even visiting, and it'll be 11 years in October 2004 with no plans to leave - love it here!)

I feel really blessed b/c the universe has guided me to where I am now.

After working crazy hours as a Software Quality Assurance Engineer for Borland, I ended up with RSI (repetitive strain injury) that put me on disability for a while and limited the amount of time (esp. continual time) that I could spend on the computer. After realizing I didn't want to stop working with computers, but that I was unhirable with the amount of breaks I'd need to take, and days off I'd need during flare-ups, as well as much frustration with voice recognition software, I finally decided to just dive in and try and make a go of things on my own. Now I'm self-employed doing Affiliate Marketing, and love the freedom of being my own boss and not wasting time sitting in endless meetings!

My family's still on the east coast, and I miss 'em a lot, especially my adorable nephews Joseph and Jacob (aged 7 and 2). Can't seem to convince any of them to move out here -- what's up with that? ;P

Interests

movies, reading, video games, xbox, ps2, gamecube, internet, dancing, spinning poi, turtles, ipod, tivo