如何用ASP实现网页伪静态页源代码

本文介绍了一种简易的方法来实现SEO友好的URL结构,并提供了使用ASP与Access数据库的具体实现步骤及代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4490194096475053&amp;dt=1225943047968&amp;lmt=1219829534&amp;prev_slotnames=1891601125&amp;output=html&amp;slotname=3685991503&amp;correlator=1225943047890&amp;url=http%3A%2F%2Fwww.corange.cn%2Farchives%2F2008%2F08%2F1453.html&amp;ea=0&amp;ref=http%3A%2F%2Fwww.corange.cn%2Fhtml%2Fcorange__75.html&amp;frm=0&amp;ga_vid=2044451421.1225934970&amp;ga_sid=1225942786&amp;ga_hid=1070165988&amp;ga_fc=true&amp;flash=9.0.124.0&amp;u_h=768&amp;u_w=1024&amp;u_ah=715&amp;u_aw=1024&amp;u_cd=32&amp;u_tz=480&amp;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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值