
Irish Developer dot com is the online playground of David Rooney a web design and developer since the age of 16. Having worked both in Ireland and America... More »
You are reading ASP SEO friendly URLs . You can leave a comment or trackback this post.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Dec | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||
Posted last year, mid-September by Dave.
Categories: SEO, ASP, VBScript, Snippets.
Post Views: 1,250 Views.
One of the down sides to ASP is not being able to make SEO friendly URLs with out the need for server components. PHP can do with use of the .htaccess file. When ASP was first thought up by Microsoft the need for SEO friendly URLs wasn’t high on the list of needs. SEO wasn’t what it is today, a key to making a site successful. With the introduction of the .NET platform saw the end of development on the ASP platform. Which left web developers in a tight spot, either they install a server component (example: custom or pre built ISAPI filters) or they had to find creative ways to get around this issue.
And the answer to this is very simple. But you will need access to custom error pages. Most of all the 404 page. Copy the current 404 page into your root directory or where ever you wish and rename it 404message.html. Now create a new 404 page called 404.asp. Set your 404 error page to the 404.asp file and in this 404.asp file copy the following code into it.
If you have a file called contact.asp, you would normally type www.yourdomain.com/contact.asp. With this you now call www.yourdomain.com/contact/ and what happens is the server throws a 404 error and the 404.asp gets called. The 404.asp looks at the string sent to it which looks like 404;http://www.yourdomain.com/contact/. Now the code will turn the sting into an array to grab the file name. But first it needs to move in 12 chars from the left to avoid the 404;http:// because we are splitting using forward slash and the first 2 forward slashes will cause errors.
Since we have now broken the sting into an array we look at aParameters(0) and add “.asp” to it and using Server.Transfer() we transfer to contact.asp. And the user gets the contact.asp page. The last part of the script catches errors caused by the Server.Transer(), the only error that will be thrown is if there really is a 404. And as you can see if there is an error set the Response.Status and redirect to our 404message.html
The file name with out the .asp should always be the aParameters(0), but you can have any number of pieces of information after it and the user and search bots will all see it as a folder structure. Below is a function for use of pages to read all other parts of the array. What it does is read from right to left. Example, if you had www.yourdomain.com/store/laptops/sony/ to get the sony part you would call GetRequest(1) for the laptops part call GetRequest(2). It also has an Internet Explorer fix. Internet explorer removes the last forward slash in your history. The function will check to see if the last char is a forward slash and if not adds it.
So as you can see getting SEO friendly URLs with ASP is simple enough. For more information about search engine optimization for web sites please visit, Ireland SEO Marketing
2 comments.
Print
Email
PDF
SEO, ASP, VBScript, Snippets, 404, asp, http, IIS, microsoft, sony, vbscript
Comment on November 27th, 2007 .
Hi, thanks for this tips.. how about the url structure I am using right now? Please give some advice if I should change it. I use /%category%/%postname%.html
It forms a url like this: http://xteb.net/seotips/wordpress-seo-strategies.html
Hope to hear back from you ![]()
John
Comment on November 28th, 2007 .
John, Thats an okay structure. Except you cant use .html with the above script. I would myself go with something like http://xteb.net/seo/tips/wordpress-seo-strategies/
Comments can contain some xhtml. Names and emails are required (emails aren't displayed), url's are optional.