1. Use isapi_rewrite to dynamically link and rewrite the html static URL. isapi_rewrite is a DLL component, and re_write is a module in iis. This filter implementation uses regular expressions to map dynamic web URLs to static URLs. If you can convert ?id=95 to news/ through re_write. The mapped regular expression is set in the file.
To give a small example: to deal with data page turn, the writing method is:
more_<%=page%>_<%=type%>.html (Note: page is the number of pages turned, type is the data type) Expression form: more_1_95.html
If you turn to the next page, it is: more_2_95.html, and continue the loop of the next page, it is:
more_3_95.html, and so on.
However, you need to add the following code to the file:
rewriterulle /more_(d+)_(d+).html /jsp tutorial/?page=$1&type=$2 [n,i] string 9
If your dynamic program has multiple parameters to be passed, then add multiple (d+), as follows:
rewriterule /more_(d+)_(d+)_(d+).html /asp/?page=$1&type=$2&type2=$3 [n,i]
Advantages: There is basically no need to make any changes in the program. Trouble: To achieve this, you need to control IIS, so when you rent someone else’s server, you need to contact the service provider first. (Of course this is for Asp, so there is no need to do the tutorial - you can directly put the DLL assembly into the bin in the program and then configure it appropriately)
2. iis's 404 error handling mechanism: By customizing errors, turn to the processing page we prepared. However, this scalability needs to be studied, and the overall requirements for program processing are also high, and it is not very suitable for practical applications.
First, set site properties - custom errors
Find http error 404, and then edit the properties -> Message type and select url->url to fill in "/", or your error handling page.
In this way, for example, when a user or spider visits http://cn/ (12345 is the id of the article in the database tutorial). Since some pages do not exist, a 404 error was triggered. Turning to
In Riga
currdomain=("http_host") 'Currently accessed domain name
currurl=replace(("query_string"),"404;http://"&currdomain&":80","") 'Currurl accessed
The currurl at this time should be: .
3.
1. Create a new folder info (because the page url of the final access information is http://localhost/info/?)
2. Create a new file in the info folder (that is the page on the default homepage)
The content of the file is as follows
<%
currdomain=("http_host") 'Currently accessed domain name
currurl=replace(("query_string"),"404;http://"&currdomain&"/info/?","") 'Currurl accessed
id=replace(currurl,".html","")
%>
where id is the passed parameter
If there are multiple parameters, can the url be pseudo-static to info/?
Among them, 1, 2, and 3 each represent the values of three parameters, and the separated strings can be proposed separately.
Real html static page
Write html code into a file and generate a file in .html format
<%
filename=""
if request("body")<>"" then
set fso = ("")
set htmlwrite = ((""filename""))
"<html><head><title>" ("title") "</title></head>"
"<body>Output title content: " ("title") "<br />Output body content:" ("body") "</body></html>"
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>
<input type="submit" name="submit" value="generate html">
</form>
2. However, it is very inconvenient to generate html files according to the above method. The second method is to use template technology to replace the value of the special code in the template with the value accepted from the form or database field to complete the template function; to generate html files from all the template codes that were finally replaced. This technology is used more, and most cms use this method.
' //Template file
<html>
<head>
<title>$title$ by </title>
</head>
<body>
$body$
</body>
</html> '// Generate html
<%
dim fso,htmlwrite
dim strtitle,strcontent,strout
'// Create a file system object
set fso=("")
'// Open the web template file and read the template content
set htmlwrite=((""))
strout=
strtextle="generated webpage title"
strcontent="generated web page content"
'// Replace the tags in the template with real content
strout=replace(strout,"$title$",strtitle)
strout=replace(strout,"$body$",strcontent)
'// Create the static page to be generated
set htmlwrite=((""),true)
'// Write content to the web page
strout
"The static page was generated successfully!"
'// Release the file system object
set htmlwrite=nothing
set fso=nothing
%>