ASP程序实现网页伪静态页源代码
生活随笔
收集整理的這篇文章主要介紹了
ASP程序实现网页伪静态页源代码
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
很簡單的教程,獻(xiàn)給喜歡SEO的朋友們。把http://www.***.cn/article.asp?logID=26 替換成http://www.***.cn/article.asp?/a26.html。不需要通過iis+ISAPI_Rewrite做基于IIS的url rewrite 一、數(shù)據(jù)庫很簡單使用ACCESS,Data.mdb建立一個表Article,三個字段:ID,Title,Content;自動編號、標(biāo)題、文章內(nèi)容。 二、Config.asp ASP/Visual Basic代碼 <% '數(shù)據(jù)庫鏈接 db="data.mdb" Set conn = Server.CreateObject("ADODB.Connection") connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db) conn.open connstr If Err Then err.Clear Set conn = Nothing Response.Write "數(shù)據(jù)庫連接出錯,請檢查連接字串。" Response.End End If '定義新聞閱讀界面的讀取 Dim News_title,News_content Sub ReadNews() set rs1=server.createobject("adodb.recordset") sql1="select id,title,content from article where id="& ID rs1.open sql1,conn,3,3 News_title=rs1("title") News_content=rs1("content") rs1.close set rs1=Nothing End Sub %> 三、Default.asp 以下為引用的內(nèi)容: ASP/Visual Basic代碼 <% Set rs=server.CreateObject("adodb.recordset") sql="select * from Article" rs.open sql,conn,1,1 do while not rs.eof %> .html"><%=left(trim(rs("title")),30)%> <% rs.movenext loop rs.close set rs=Nothing %>
四、Article.asp ASP/Visual Basic代碼 <% id=request.QueryString("id") If id="" Then server_v40=Request.ServerVariables("QUERY_STRING") id=Int(replace(replace(server_v40,"/",""),".html","")) End If Call ReadNews() %>
標(biāo)題: <%= News_title%>
內(nèi)容: <%=News_content%> 這個教程已經(jīng)能實(shí)現(xiàn)最基本的功能,具體大家就想怎么應(yīng)用就八仙過海,各顯神通了! 《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀
內(nèi)容: <%=News_content%> 這個教程已經(jīng)能實(shí)現(xiàn)最基本的功能,具體大家就想怎么應(yīng)用就八仙過海,各顯神通了! 《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀
總結(jié)
以上是生活随笔為你收集整理的ASP程序实现网页伪静态页源代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 九种破解Xp登录密码方法
- 下一篇: Select下拉列表框(添加、删除opt