Wednesday, August 30, 2006

Rewriting your URL’s for SEO

I am constantly asked how to re-write URL’s to make them search engine friendly. I know this seems complicated, but if you think about it very carefully it's actually very easy. Here are a few examples of how you can re-write your URL’s.

This example is only good for apache

1). You must have the module: mod_rewrite installed on apache

2). You need to use a .htaccess file to build the functions, if you don’t have one don’t worry. Just create a text file with this content and upload it.

First line, turn on the engine

RewriteEngine on

Second line, tell the engine where it needs to work

RewriteBase /

Now you can specify your re-writes, here are 3 examples.

1). Your URL looks like this? http://www.mysite.com/index.php?page=privacy <- This suck for SEO right?
So your rewrite rule would be,

RewriteRule ^privacy.html$ index.php?page=privacy

Now you can change your anchor link to http://www.mysite.com/privacy.html

2). If your URL looks this? http://www.mysite.com/index.php?page=story&storyid=66 Wow this really sucks for SEO!
This re-write is a little more complicated, you need to match the numbers.

RewriteRule ^story([^/]+).htm$ index.php?page=showstory&storyid=$1

Now you can point your links to http://www.mysite.com/story66.htm This will really help!

3). If your URL looks like this? http://www.mysite.com/user.php?username=myuserid This can be very difficult, because now you have a possibility of non Alpha Numeric lettering. So we need a string that can handle all of them.

RewriteRule ^([a-zA-Z0-9_-]+)$ showprofile.php?username=$1 [QSA,L]

Now you can point your links to http://www.mysite.com/myuserid

Personally I like usernames, not to have an extension on them for easy tracking. But you can easily add a .htm to the end by just changing it to.

RewriteRule ^([a-zA-Z0-9_-]+).htm$ showprofile.php?username=$1 [QSA,L]

Now I cannot easily tell you how to fix your links in your code, since every site is a little different but give it a shot. You can always post questions here in the comments section of this post.

Labels: ,

0 Comments:

Post a Comment

<< Home

My Photo
Name: Aaron Shear
Location: San Francisco, California, United States

I have been in the search industry since the late 90’s, no not 10-20 years. My career started early in the search Day’s at Inktomi, where I supported large search portals. For example, MSN, AOL, iWon, Hotbot, CNet too name a few. After Inktomi I became a freelance consultant. I consulted for a few of the Top SEO’s around 2002 time frame; obviously the market has changed since then. After consulting I joined a small SEO firm called SEO Inc as the CTO. At SEO Inc. I successfully optimized some of the largest clients including IGN, Sony, VEGAS.com, Beaches and Sandals Resorts to name a few. Even though SEO Inc was a ton of fun, I still wanted the ultimate SEO challenge. I moved on as the global head of SEO for Shopping.com an eBay company. This challenge was an interesting one, how do I optimize a site with 50 million products? Every month I helped the business grow by leaps and bounds. I am now consulting for mostly enterprise e-commerce clients. Yes there is more too me than this profile shows, but you will just have to ask.

Powered by Blogger

Add to Google Subscribe in Bloglines