..
How many of you already know, the optimization techniques to discourage search engines in order to obtain a better index your site, using web pages with querystring, since our goal far more effective than the common physical file or URL rewritten by an ad hoc system of URL Rewriting.
In this article we dynamically manage the transformation of our content (news, articles, product sheets, etc..) To create (or simulate) physical files optimized for better performance on search engines.
To give a concrete example let's say having to optimize a sports and news portal, just to remember happy times, back to 2006 when the Italian national team won the World Cup, the day when our hypothetical site would have certainly published a story with a title like this:
World champion Italy: Cannavaro lifts the Cup!A dynamic site written in ASP could use a file with querystring, he found the record ID from the database, for example:
/ Notizia.asp? Id = 100but, as we said, would be a much better physical file type:
Italy-the-world-champion-cannavaro-up-the-coppa.aspWhat is this file actually exists or is a simple simulation (URL rewriting) is not relevant at this time: our aim is simply to take the title of the news and treat it so that it conforms to ISO on writing URLs, since a file with a name like:
World champion Italy: Cannavaro lifts the Cup!. Aspwould be rather ugly, but most non-compliant!
In order we can create a function, include it in the configuration file of our site and use it as a filter to treat as befits the title, in order to write well for the name of the file.
The function we will examine is quite comprehensive and covers all the Italian special keyboard characters, accented letters and so on, also uses the hyphen (-) separator.
The complete code follows:
<%
Function FileName (FN)
Fn = Replace (fn, "", "-")
Fn = Replace (fn, "_", "-")
Fn = Replace (fn, "a", "a")
Fn = Replace (fn, "is", "e")
Fn = Replace (fn, "es", "i")
Fn = Replace (fn, "ò", "o")
Fn = Replace (fn, "U", "u")
Fn = Replace (fn, ".", "")
Fn = Replace (fn, "", "")
Fn = Replace (fn, ":" "")
Fn = Replace (fn, "", "")
Fn = Replace (fn, "", "")
Fn = Replace (fn, "", "")
Fn = Replace (fn, "'" "")
Fn = Replace (fn, """", "")
Fn = Replace (fn, "(", "")
Fn = Replace (fn, ")", "")
Fn = Replace (fn, "[", "")
Fn = Replace (fn, "]", "")
Fn = Replace (fn, "{", "")
Fn = Replace (fn, "}", "")
Fn = Replace (fn, "/", "")
Fn = Replace (fn, "\" "")
Fn = Replace (fn, "|", "")
Fn = Replace (fn, "£", "")
Fn = Replace (fn, "$", "")
Fn = Replace (fn, "%", "")
Fn = Replace (fn, "+", "")
Fn = Replace (fn, "@", "")
Fn = Replace (fn, "*", "")
Fn = Replace (fn, "=", "")
Fn = Replace (fn, "#", "")
Fn = Replace (fn, "<", "")
Fn = Replace (fn, ">", "")
FileName = LCase (FN)
End Function
%>
To test the function you try to print any phrase on the screen that contains a series of characters that we went to manage.
For example:
<%
FileName Response.Write ("Hello, how are you?")
%>
returns:
hello-how-areDepending on our needs, therefore, we can dynamically create the physical file on our home page, or simply move with a system of taking care of writing URL Rewriting rewriting rules in accordance with the workings of our function.
| |
ASP (Advanced)
Full course for creating dynamic Web sites. From 39 €. |
| |
ASP Zero (Ebook)
Learning Microsoft ASP and VBScript from scratch. At only 29 €. |
| |
ASP.NET (Course)
Full course for building Web applications from 49 €. |