Site   Web

March 6, 2009

Use Descriptive URLs to Bolster Your Search Engine Rankings!

Dynamically generated pages, such as those made by PHP scripts, usually have URLs that aren’t very readable, like “mysite.com/script.php?id=3951&page=2″. The URL doesn’t say anything at all as to what the page is, other than showing that it’s generated by a script. If you want to make your dynamic pages more search engine friendly, rewrite your scripts to use descriptive URLs!

A URL like “mysite.com/blogpost/3951-People-Know-What-This-Is.html” would be a lot better, wouldn’t it? Right off the bat, you know what the page is about. If you’re scrolling through your recent pages, you can find exactly what you’re looking for a lot easier. More importantly though, search engines love URLs like these, so you get a nice rankings boost!

As a PHP programmer, I’m going to detail this technique with PHP, but the same principle applies to whatever serverside scripting language you use.

To start, have the script execute as a file without the extension, instead of with the .php extension (or or .jsp, or whatever extension your language uses). On Apache servers, you can use a ForceType statement in the .htaccess file to make the script execute as application/x-httpd-php. This tells Apache to run the file as a script instead of just spitting out your code.

Right now, your script should work properly as “mysite.com/script?id=3951&page=2″. It’s no longer readily apparent which language your site uses, but you can still tell that it’s a dynamic page. Let’s fix that next, by using PHP’s explode function to break up the argument list. Using this, the arguments to your script will look like folders on your server instead of parameters to a script:

$args = explode(“/”,$_SERVER[‘PHP_SELF’]);

Now, if you were to access “mysite.com/script/3951/2″, $args would become an array with “3951” and “2”. You can replace the slash with a hyphen to separate arguments without making them look like directory entries, or use a second explode statement to break down some of the arguments in a different way.

Finally, write some code that converts the title of the content (be it the blog post name, forum topic, etc.) into an argument, substituting dashes for spaces. Some people use underscores instead of dashes, but the search engines don’t see underscored words as separate terms, so you end up with the search engine thinking “This_Is_My_Post” is one big word.

Add a pinch of code at the top of the script to make ensure that the URL matches the one you want it to be (so it redirects thread/4614-wrong-name-1 to thread/4614-This-is-my-posts-name-1), then add .html to the end of it (so it looks like an innocent html file) and you’re good to go!

To prevent stuffing the url with words that don’t really matter, use the string replace functions to remove words such as “I”, “The”, and “And” from the URL.

Most search engines won’t completely index your website if it’s all stuffed into argument lists, so by having URLs that look like normal filenames you both ensure that all of your pages are indexed and increase your search engine optimization. Making your URLs readable by humans is juts an added bonus. Make sure to update the links within your site to reflect your new URLs, so your page doesn’t turn into a smattering of redirects.

About the Author: Phil runs a web development resource site. Find yourself asking, Where do I buy web hosting? Read all about it on Phil’s site!

One Response to “Use Descriptive URLs to Bolster Your Search Engine Rankings!

    avatar SiteProNews: Webmaster News amp; Resources » Blog Archive » Use b…/b | Free Full Rapidshare Downloads says:

    […] View post: SiteProNews: Webmaster News amp; Resources » Blog Archive » Use b…/b […]

Submit a Comment

Your email address will not be published. Required fields are marked *






You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Please leave these two fields as-is:

Protected by Invisible Defender. Showed 403 to 4,243,314 bad guys.

css.php