There are many reasons a webmaster may want to change the look and feel of a web page address. They may have dynamic URLs that need to be search engine-friendly, the page may have moved, the whole site may have moved to a new domain name, or they need to be better for users to view as interesting in the SERPs for more traffic and searchability. Whatever a webmaster’s reasons for changing the way a URL is handled, there are definitely good ways to do this in regard to SEO, and then there are some bad ones, too.

In this article I want to look at a few ways you can utilize a few simple server tools and redirection elements to provide your site with static-looking search engine friendly URLs.

Dynamic URLs

There are two types of URLs: dynamic and static. A dynamic URL is a page address that results from the search of a database-driven web site or the URL of a web site that runs a script. In contrast to static URLs, in which the contents of the web page stay the same unless the changes are hard-coded into the HTML, dynamic URLs are generated from specific queries to a site’s database. The dynamic page is basically only a template in which to display the results of the database query. Instead of changing information in the HTML code, the data is changed in the database.

Because of the way that dynamic URLs are created, they sometimes create nightmares in the area of search engine optimization (SEO). Search engines do not like to index dynamic URLs. There are multiple reasons for this, one of them being the non-standard characters like ?, &, %, =, and others in the URL. Many times, anything after the character is disregarded. For example, we may have URLs that look something like this:

Any URL that is viewed this way to a search engine is going to essentially be nothing more than a bunch of duplicate URLs. And we all know how much search engines just love duplicate URLs. (Okay, I was being sarcastic, as they don’t). They would much rather index a URL that looks like this:

http://www.somesite.com/index.php/seo_tools_page.html

In other areas, many times dynamic content is hard to spider, especially if it is pulled from the database with client-side code like JavaScript. If you can’t view the page source and view the content of a web page, there is a very good chance that a search engine spider will not be able to either. While search engines are getting much better at indexing dynamic URLs, they would still prefer static URLs.

So the challenge of dynamic URLs is clear: how do you keep the dynamic site without compromising the indexing of your pages with regard to SEO? By creating search engine-friendly (SEF) URLs, that’s how! Let’s look at a few methods we want to be familiar with in our quest for SEF URLs. Quite frankly, it may sound like a daunting mission, but it’s certainly not a mission impossible.

The first and most obvious way you could do this would be to rename every page in your site to reflect a static URL with keywords and make those pages static. If you have only a few pages in your site, then you probably don’t need a dynamic site in the first place, so this would be fine. But if you have a dynamic site that produces hundreds or even thousands of URLs, then doing this by hand is an unreasonable task to undertake. So you will either need to figure out a different way to accomplish the same thing, or find a tool to do it for you.

Using .htaccess

In the next couple of items I’ll explain a bit further. The .htaccess file is basically a set of instructions in a simple text file with the extension .htaccess (there is no file name) on the server to give parameters to the browser when a request is made, put quite simply. More specifically, it is a web server configuration file that contains commands known by the server that tell the server how to behave in certain instances. The place you would utilize mod_rewrite or other redirect-type tools available to you will most likely be in your .htaccess file.

Some of the most common uses of an htaccess file include the capability to restrict access to certain files or directories on the Internet (or intranet) through password protection. Additionally htaccess is used to automatically redirect users, ban or allow certain IP addresses access to the server, and to call a custom designed 404 error page rather than the standard error 404 file that usually appears in your browser. Apache Web servers and other NCSA compliant Web servers can use htaccess.

Most search engines, especially all major ones, will not index pages with query strings because it may also indicate that the content of the page is not static and it prevents spamming to some extent. There’s multiple ways to disguise the query string though. The easiest and probably most used involves mod_rewrite on Apache servers.

If your server is hosted on a Linux or Unix (*nix) server, then you may have access to Apache’s module called mod_rewrite. This is a nifty module indeed. What it does is return to the browser a URL that appears to be the actual web address of the page, when in fact the URL itself is not being changed in any way. It’s more of a mirror effect.

When a request comes in to a server for the new static URL through mod_rewrite, the Apache module redirects the URL internally to the old, dynamic URL, while still appearing to all the world, search engines included, as the static URL. The web server compares the URL requested by the client with the search pattern in the individual rules. For example, when someone requests the SEF URL:

http://www.somesite.com/index-forumid/120957w/0404200620%
search.htm

The server looks for and compares this static-looking URL to what information is listed in the .htaccess file, such as:

So what if you are on a Microsoft IIS server? Well, there is another way to accomplish this using code, but it’s far more painful to use than mod_rewrite. But it can certainly be done. Unfortunately for the time being, that is outside the scope of this article.

301 vs. 302 Redirects

Redirects can either be good or bad as far as SEF URLs are concerned. 302 redirects are temporary redirects. These tell a search engine spider that you’ve moved this page only temporarily and to index it later when you have moved it to a new home for good. While this may not be what you actually had in mind to do, that’s how a search engine reads a 302 redirect. Use instead a 301 permanent redirect. It’s the 301 redirect that informs the search engine of the new URL and to start indexing it instead of the old URL. 301 redirects are also fairly seamless, so your visitors will also probably not be aware of the move, and if they’ve bookmarked a particular page, this will be especially helpful.

If you are not willing or don’t know how to write a script to reprogram your dynamic URLs into static ones, then you are in luck, because there are many tools available on the web that will help you produce the code you need to enable you to create SEF URLs. You might want to consider a Windows code generator if you are on an MS IIS server.

Incorporating Keywords

You may be thinking to yourself, “Well, okay, the rewritten URL looks a bit better, but it doesn’t contain any keywords, and certainly doesn’t mean anything to me or my visitors. Now what?” Search engines are 66% to 85% more likely to list your web page in its top ten results if you utilize a keyword or phrase in the URL. So not only should you master the techniques of creating SEF URLs, you should also try to get a few highly targeted keywords placed in that SEF URL. Now, we’re just making this whole thing too complicated, right? Not necessarily. Keep in mind that it is up to you to decide how your URL will ultimately look.

So while we are creating our SEF URL, we simply plant a few of the keywords into the code for redirection or rewrite. Let me show you a little bit of what I mean. Let’s say we want our URL to look like this:

http://www.somesite.com/index.php/seo_tools_page.html

We’ll have to take our earlier code and expand it a bit more, make it URL specific and cover multiple parameters. We may just need to add a few tweaks to incorporate the keywords where we want them. You will probably do better to find information on the specific code to do this by doing a search for mod_rewrite, as it is outside the scope of this article. Essentially there are three key steps to any mod_rewrite directive:

RewriteRule thisfile changedfilename

There are clearly more things that will go into all of this that I haven’t covered, nor do I have the time and in the case of mod_rewrite, the knowledge to do everything you need to create the perfect SEF URLs. This article is not necessarily intended to give you all the specific instructions to utilize mod_rewrite completely effectively on all of your pages, for example, but it’s a fair start.