<iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4490194096475053&dt=1225943047968&lmt=1219829534&prev_slotnames=1891601125&output=html&slotname=3685991503&correlator=1225943047890&url=http%3A%2F%2Fwww.corange.cn%2Farchives%2F2008%2F08%2F1453.html&ea=0&ref=http%3A%2F%2Fwww.corange.cn%2Fhtml%2Fcorange__75.html&frm=0&ga_vid=2044451421.1225934970&ga_sid=1225942786&ga_hid=1070165988&ga_fc=true&flash=9.0.124.0&u_h=768&u_w=1024&u_ah=715&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="300" scrolling="no" height="250" allowtransparency></iframe>
很简单的教程,献给喜欢SEO的朋友们。把http://www.***.cn/article.asp?logID=26替换成http://www.***.cn/article.asp?/a26.html。不需要通过iis+ISAPI_Rewrite做基于IIS的urlrewrite
一、数据库很简单使用ACCESS,Data.mdb建立一个表Article,三个字段:ID,Title,Content;自动编号、标题、文章内容。
二、Config.asp
ASP/VisualBasic代码
<%
'数据库链接
db="data.mdb"
Setconn=Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath(db)
conn.openconnstr
IfErrThen
err.Clear
Setconn=Nothing
Response.Write"数据库连接出错,请检查连接字串。"
Response.End
EndIf
'定义新闻阅读界面的读取
DimNews_title,News_content
SubReadNews()
setrs1=server.createobject("adodb.recordset")
sql1="selectid,title,contentfromarticlewhereid="&ID
rs1.opensql1,conn,3,3
News_title=rs1("title")
News_content=rs1("content")
rs1.close
setrs1=Nothing
EndSub
%>
三、Default.asp
ASP/VisualBasic代码
<!--#includefile="config.asp"-->
<ol>
<%
Setrs=server.CreateObject("adodb.recordset")
sql="select*fromArticle"
rs.opensql,conn,1,1
dowhilenotrs.eof
%>
<li><ahref="article.asp?/<%=rs("id")%>.html"><%=left(trim(rs("title")),30)%></a></li>
<%
rs.movenext
loop
rs.close
setrs=Nothing
%>
</ol>
四、Article.asp
ASP/VisualBasic代码
<!--#includefile="config.asp"-->
<%
id=request.QueryString("id")
Ifid=""Then
server_v40=Request.ServerVariables("QUERY_STRING")
id=Int(replace(replace(server_v40,"/",""),".html",""))
EndIf
CallReadNews()
%>
<div>
标题:<b><%=News_title%></b><br/>
内容:<%=News_content%>
</div>