Dramatically Increase Dynamic Page SEO With Descriptive URLs
Dynamic pages tend to have URLs that read horribly, such as:
“mysite.com/thread.php?id=3951&page=2”
The URL says absolutely nothing about what the page is, other than that it’s probably a thread. If yours look like that, you’re missing out on a valuable way for gaining extra search engine optimization.
Wouldn’t a URL like:
“mysite.com/thread/3951-Bubblewrap-Is-Delicious-2.html”
look a lot better? First, you know just from reading the URL exactly what the page is about: If you want to find out about how delicious bubble wrap is, that’s a page you want to look at. Second, and more importantly, search engines give extra ranking to keywords present in the URL.
The technical parts of this guide will differ based on which scripting language you’re using. I’ll be using PHP, but there are similar ways to accomplish this with the other languages.
First, you should make the script run as a file without an extension, rather than a .php extension (or whichever extension your language uses). I added a ForceType statement to my .htaccess file, to make the thread file read as application/x-httpd-php, a PHP script.
At this point, your script would run properly as “mysite.com/thread?id=3951&page=2”. This is already better, because it doesn’t give away which scripting language you use. It doesn’t accomplish anything in terms of SEO though.
Next, you should to break up the arguments that are passed to our script with the “explode” function, like so:
$args = explode(“/”,$_SERVER[‘PHP_SELF’]);
If you were to access “mysite.com/thread/3951/2”, $args would be an array with “3951” and “2”. You can use a second explode statement (or a strtok statement) to allow the two arguments to be separated by a hyphen, but do that later as the most important part is next.
Finally, convert the name of the document (be in the forum thread name or blog post name) into an argument, replacing spaces with dashes. You might notice some sites using underscores, but I’ve found that words separated by underscores are counted as a single word, instead of multiple words. If you leave them as spaces, though, they end up being turned into a garbled mess.
Add a bit of code at the top of the script that you’re optimizing to make sure that the URL matches the one you want it to be (so it redirects thread/4614-blah-1 to thread/4614-Styrofoam-Is-Good-Too-1), add .html to the end of the whole mess, and you’re done!
To prevent overuse of words that don’t actively contribute to SEO, you can use the string replace functions to strip words such as “I”, “The”, and “And” from the URL.
Many search engines won’t fully index your website if everything is behind standard argument lists, so by giving them URLs that look like proper filenames, you both ensure that all of your pages are indexed and increase your SEO relevancy. Making your URLs readable by humans is an added bonus, too.