alexgeek's Web Design and Development Blog Logo The mindless banter that is,

AlexGeek's Web Design and Development Blog

Clean URLs

22 Oct 2007 - Category: Web-Development

I finally got round to learning regex (regular-expressions). This meant I could have clean URLs for my blog entries, for an example look where you type URLs in; You should see that the URL does not have an extension! Looks a lot nicer, ey?

The only problem was, I was at risk to duplicate content attacks from competitor sites (not that I have any!).
Therefor I had to devise a way to redirect all incorrect URLs to the right one. Before, the following would all work:

  • /blog/3-testing-entry
  • /blog/3-this-is-a-dupe
  • /blog/3-lalallala
  • etc..

As you can see, I would only want google to index the first one that is in bold. This is because if google were to follow any of the other links, it would index that site as another page of my site with exactly the same content! Very bad for SEO!

How did I counter this SEO problem? Quite simple! Each blog entry of this site is pulled from a database, so I simply added another column called link that was a combination of the blog ID and it's title.
Example; ID: 3 and title: "Testing entry".

Then when the page is called I check whether the requested page was in the database via the following PHP command.

$_SERVER['REQUEST_URI'];

This checks what is used to access the page, so if this does not match the link column for that particular entry it will redirect you to the correct page!

Thanks to Rob Founder of Webforumz for his thread on this which warned me and to the regular-expressions site which helped me understand regex!

Post A Comment

Name:Email:

What is 7 + 0?

Anete Hakkinen - 22 Mar 2011

It is very interesting for me to read that article. Thanx for it. I like such topics and anything that is connected to this matter. I would like to read a bit more soon.

Anete Hakkinen
escort milano aggiungi link

Gump - 12 Jun 2011

YMMD with that awsenr! TX

vxyjtfk - 13 Jun 2011

Q3KyS8 vzowisrzqpta

qxibilgrur - 14 Jun 2011

79e2d0 bubgrlivtdvp