There are several ways to implement static HTML page, one is to use the isapi_rewrite dynamic link to rewrite the HTML static URL, one is to use the ASP program to instance, example 2,3 oh, there is a real static page, see example Four.
1, use isapi_rewrite for dynamic link rewrite HTML static URL. Isapi_rewrite is a DLL component, and Re_write is a module in IIS. This filter implementation is a regular expression, the Dynamic Web site map into a static web site. If news.asp?id=95 can be converted to news/95.html by Re_write. The mapped regular expression is set in the Httpd.ini file.
As a small example: processing data paging, then the writing is:
more_<%=page%>_<%=type%>.html (Note: page is page number of pages, type is data type) representation: more_1_95.html
If the next page is: more_2_95.html, continue to the next page of the loop, then:
More_3_95.html, and so on.
But you need to add the following code to the Httpd.ini file:
Rewriterule/more_ (d+) _ (d+). html/jsp tutorials/more.asp?page=$1&type=$2 [N,i] string 9
If your dynamic program has multiple parameters that need to be passed, add more than one (d+), as follows:
Rewriterule/more_ (d+) _ (d+) _ (d+). html/asp/more.asp?page=$1&type=$2&type2=$3 [N,i]
Advantages: Basically do not need to do any changes in the procedure. Trouble: To implement this requires control of IIS, so when you rent someone else's server, you need to contact the service provider first. (Of course this is for the ASP, the ASP.net tutorial does not--directly put the DLL assembly in the program bin and then appropriate configuration can be implemented)
2, IIS 404 error handling mechanism: Through the custom error, to our prepared processing page. However, this kind of scalability needs to be studied, and the overall requirements for procedural processing are high, which is not suitable for practical application.
First, set the site properties-Self-tuning error
Locate HTTP Error 404, and then edit the property-> message type Select Url->url to fill in "/index.asp" or your error-handling page.
This way, for example, when a user or spider accesses the http://cn/12345.html (12345 for the article in the Database tutorial ID). A 404 error was triggered because some pages did not exist. turned to index.asp.
In index.asp Riga
Currdomain=request.servervariables ("Http_host") ' Current access domain name
Currurl=replace (Request.ServerVariables ("query_string"), "404;http://" &currdomain& ": 80", "") ' Current access URL
This time the Currurl should be: 12345.html.
3.
1. Create a new folder info (because the page URL for the final access information is http://localhost/info/?1.html)
2. Under the Info folder to create a new Default.asp file (that is, the default home page)
The contents of the Default.asp file are as follows
<%
Currdomain=request.servervariables ("Http_host") ' Current access domain name
Currurl=replace (Request.ServerVariables ("query_string"), "404;http://" &currdomain& "/info/?", "") ' Current access URL
Id=replace (Currurl, ". html", "")
%>
Where ID is the parameter passed in
If it is multiple parameters, url pseudo static can be converted to info/?1-2-3.html
1,2,3 each represents the value of three parameters, separate strings are presented separately.
Real HTML static page
Write HTML code to a file and generate an. HTML-formatted file
<%
filename= "test.htm"
If Request ("Body") <> "" Then
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
Set htmlwrite = Fso.createtextfile (server.m Appath ("filename"))
Htmlwrite.write " Htmlwrite.write" <body> output title: "Request.Form (" title ")" <br/> Output Body content: "R Equest.form ("Body") "</body> Htmlwrite.close
Set fout=nothing
Set fso=nothing
End If
%>
<form name= "form" method= "POST" action= "" >
<input name= "title" value= "title "Size=26>
<br>
<textarea name=" Body ">body</textarea>
<br>
<BR&G T
<input type= "Submit" name= "submit" value= "Generate HTML" >
</form>
2, but according to the above method to generate HTML file is very inconvenient, the second approach is to use template technology to replace the value of special code in the template with a value accepted from the form or database field, complete the template function, and generate an HTML file for all the template code that is eventually replaced. This technique is used more, Most CMS uses this type of method.
Template.htm '//template file
<title> $title $ by aspid.cn</title>
<body>
$body $
</body>
<%
Dim fso,htmlwrite
Dim strtitle,strcontent,strout
'//Create File system objects
Set Fso=server.createobject ("Scripting.FileSystemObject")
'//Open page template file, read template content
Set Htmlwrite=fso.opentextfile (Server.MapPath ("template.htm"))
Strout=f.readall
Htmlwrite.close
strtitle= "generated page title"
strcontent= "generated Web page content"
'//Replace the tag in the template with the real content
Strout=replace (Strout, "$title $", strtitle)
Strout=replace (Strout, "$body $", strcontent)
'//Create a static page to be generated
Set Htmlwrite=fso.createtextfile (Server.MapPath ("test.htm"), true)
'//write page content
Htmlwrite.writeline Strout
Htmlwrite.close
Response.Write "Generate static page success!" "
'//Release File system objects
Set htmlwrite=nothing
Set fso=nothing
%>