当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP程序实现网页伪静态页源代码

ASP
简单ASP论坛DIY
如何防止页面中的敏感信息被提取
asp创建对象及中文显示解决技巧
基础开发入门级:JSP与ASP的比较
数据库受到限制怎么办?
ASP初学者常犯的几个错误
Asp定时执行操作、Asp定时读取数据库(网页定时操作详解)
ASP优化:非常实用的ASP提速技巧五则
ASP教程:解决ASP脚本运行超时的方法
ASP安全:简单学习ASP连接数据库方法
简单一招用ASP实现对IE地址栏参数的判断
asp控制xml数据库的6段非常的经典代码
ASP进阶:验证身份证号是否正确的代码
ASP教程:使用ASP生成图片彩色校验码
ASP进阶:用ASP判断文件地址是否有效
ASP进阶:用asp做的简单搜索引擎代码
ASP实例 挂QQ的网页源代码ASP/PHP
ASP答疑 解决ASP脚本运行超时的方法
轻轻松松破解开别人ASP木马密码的方法
用ASP操作Access数据库 ADOX的使用

ASP程序实现网页伪静态页源代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 72 ::
收藏到网摘: n/a

很简单的教程,献给喜欢SEO的朋友们。把http://www.***.cn/article.asp?logID=26   替换成http://www.***.cn/article.asp?/a26.html。不需要通过iis+ISAPI_Rewrite做基于IIS的url rewrite

一、数据库很简单使用ACCESS,Data.mdb建立一个表Article,三个字段:ID,Title,Content;自动编号、标题、文章内容。

二、Config.asp
ASP/Visual Basic代码

以下为引用的内容:
<%   
'数据库链接   
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 "数据库连接出错,请检查连接字串。"  
        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

以下为引用的内容:
ASP/Visual Basic代码
<!--#include file="config.asp"-->   
<ol>   
<%   
Set rs=server.CreateObject("adodb.recordset")   
sql="select * from Article"  
rs.open sql,conn,1,1   
do while not rs.eof   
%>   
<li><a href="article.asp?/<%=rs("id")%>.html"><%=left(trim(rs("title")),30)%></a></li>   
<%   
rs.movenext   
loop   
rs.close   
set rs=Nothing  
%>   
</ol>  

四、Article.asp

ASP/Visual Basic代码

以下为引用的内容:
<!--#include file="config.asp"-->   
<%   
id=request.QueryString("id")   
If id="" Then    
server_v40=Request.ServerVariables("QUERY_STRING")   
id=Int(replace(replace(server_v40,"/",""),".html",""))   
End If    
Call ReadNews()   
%>   
<div>   
标题: <b><%= News_title%></b><br />   
内容: <%=News_content%>   
</div>  

这个教程已经能实现最基本的功能,具体大家就想怎么应用就八仙过海,各显神通了!