asp伪静态

地址格式如:http://localhost/?news_list.html

Rem niky_,asp伪静态处理
Rem 10-09-18
Rem http://wei0523123.iteye.com/

On Error Resume Next
Dim query_string,param_str,arrParams,module,mod_url
Dim arrItems

query_string 	= Request.QueryString()
param_str		= Replace(query_string,".html","")
'以"_"分割param_str
arrParams		= Split(param_str,"_",-1,1)
module			= arrParams(0)
'如果不存在,默认首页index
If Err Then
	err.Clear
	module = "index_"
End If

'页面文件名数组,可以在网站初始化时存在放缓存中
'或者可以用Select的形式
Set arrItems = Server.CreateObject("Scripting.Dictionary")
arrItems.add "index_","index_.asp"
arrItems.add "news","news.asp"
arrItems.add "about","about.asp"
If arrItems.Exists(module) Then
	mod_url = arrItems.Item(module)
Else
	mod_url = "index_.asp"
End If
'页面处理
Server.Transfer(mod_url)
If Err Then
	Err.Clear
	Response.Write("不存在文件:"&mod_url&"<a href=""/"">返回首页</a>")
End If


其原理也就是解析QueryString,然后进行重定向Server.Transfer(mod_url)
简单的企业站演示: http://www.li-nong.com/

猜你喜欢

转载自wei0523123.iteye.com/blog/766600