Categories
Search Box
Latest Posts
- My Organic Modem
- Temporary Fix for the KB940510 windows update
- Practical Example of using LINQ
- Getting Started with Programming (Beginners Guide)
- Hardware Maintenance
Clean URLs
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!