ASP completely implement pseudo static HTML

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Spend more time online this time! In order to find out about the implementation of static processing of ASP dynamic content how much time I spent, looked everywhere, most of them are reproduced, almost identical, there are mainly the following methods:

1 > Write to the hard disk with the program. File stream processing for ASP FS objects. Each article has an actual path. If you want to publish a large number of content, you need large capacity space, and bad maintenance, modification is inconvenient, the advantage is to reduce the server's access burden, easy to be indexed by search engines, greatly reduce and prevent hacker attacks, a small scale of the site are all static , such as Sina, Sohu and so on.

2 > components such as Isapi_ Rewrite rewrite. have their own server webmaster Okay to do, the virtual host friend is slightly troublesome, unless the request service provider installs this plug-in, then the program parameter submits the server to realize transforms, appears is static, actually is uses the static path to access the content of the database. For search engine revenue has some effect. And many webmasters are struggling to find .

The above two methods of how to do, we search the Internet will find a lot of ...

3 > The third comparison is to turn the show.asp?id=26 into a show.asp?/26.html this may be useful for search engines But there is no safety injection. But as long as the prevention work, this method is more suitable for most of the webmaster owners. I'm here to focus on using a third method to achieve static processing.

This example implements the effect: http://faninfo.cn/news.asp?id=201

Http://faninfo.cn/news/?/201.html

(reprint please indicate the starter blog Faninfo.cn/blog)

--------------

A preparatory work

Create a new folder in the Site Directory news and create a new home page file index.asp, the database Data.mdb (field id,title,content,) and conndb.asp

Two code implementation

Data Connection File conndb.asp

<%


Dim conn


dbpath= "Data.mdb"


Set conn = Server.CreateObject ("ADODB. Connection ")


connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DBPath)


Conn.Open ConnStr


If ERR Then


Err. Clear


Set conn = Nothing


Response.Write Database connection error, please wait while you visit. "


Response.End


End If


' News reading module


Dim news_title,news_content


Sub readnews ()


set Rs1=server.createobject ("Adodb.recordset")


sql1= "Select Id,title,content from aspires where id=" & ID


Rs1.open sql1,conn,3,3


news_title=rs1 ("title")


news_content=rs1 ("content")


Rs1.close


Set rs1=nothing


End Sub


%>


News-list.asp


<!--#include file= "conndb.asp"-->
<ol>
<%
Set Rs=server. CreateObject ("Adodb.recordset")
Sql= "SELECT * from aspires"
Rs.Open sql,conn,1,1
Do as not rs.eof
%>
<li><a href= "news/?/<%=rs (" id ")%>.html" ><%=left (Trim ("title")%></a></ li> _fcksavedurl= "" "News/?/<%=rs (" id ")%>.html" ><%=left (Trim ("title")%></a></ Li> "
<%
Rs.movenext
Loop
Rs.close
Set rs=nothing
%>
</ol>

OK, now write the News body reading page news/index.asp

Index.asp

<!--#include file= "conndb.asp"-->

<%
Id=request. QueryString ("id")
If id= "" Then
Pater=request.servervariables ("Query_string")
Id=int (replace (Pater, "/", ""), ". html", "")) ' replace substitution function, such as HTML and/or empty
End If
Call Readnews ()
%>
<div>
<b><%= news_title%></b><br/> ' theme
<%=News_content%> ' body
</div>

The effect of this implementation is as follows: http://www.faninfo.cn/news/?/201.html we know Windows folder naming rules

is not allowed to contain? So here only the role of visual deception.

Also, can we convert it to this effect through the Replace function: Http://www.faninfo.cn/news/read/201.html?

This is my current summary, ready to use on my home page, demo address: http://www.faninfo.cn (unfinished), of course, I believe there will be a better solution, if interested friends please come to the site exchange.

(reprint please indicate the starter blog/blog http://faninfo.cn)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.