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. For example, you can convert news.asp?id=95 into news/95.html through re_write. The mapping regular expression is set in the httpd.ini 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 httpd.ini file:
rewriterulle /more_(d+)_(d+).html /jsp tutorial/more.asp?page=$1&type=$2 [n,i] string 9
If your dynamic program has multiple parameters to be passed, then add multiple (d+), as follows:
rewriterulle /more_(d+)_(d+)_(d+).html /asp/more.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, there is no need to do asp.net 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 "/index.asp", or your error handling page.
In this way, for example, when a user or a spider visits http://cn/12345.html (12345 is the id of the article in the database tutorial). Since some pages do not exist, a 404 error was triggered. Turning to index.asp
Add in index.asp
The code copy is as follows:
currdomain=request.servervariables("http_host") 'Current access domain name
currurl=replace(request.servervariables("query_string"),"404;http://"&currdomain&":80","") 'Currurl accessed
The currurl at this time should be: 12345.html.
3.
1. Create a new folder info (because the page URL of the final access information is http://localhost/info/?1.html)
2. Create a new default.asp file in the info folder (that is the page of the default homepage)
The contents of the default.asp file are as follows
The code copy is as follows:
<%
currdomain=request.servervariables("http_host") 'Current access domain name
currurl=replace(request.servervariables("query_string"),"404;http://"&currdomain&"/info/?","") 'Curror accessed url
id=replace(currurl,".html","")
%>
where id is the passed parameter
If there are multiple parameters, you can pseudo-statically turn the url into info/?1-2-3.html
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
The code copy is as follows:
<%
filename="test.htm"
if request("body")<>"" then