塞维利亚地图
加入收藏    手機頻道
當前位置:首頁  >>  網頁設計
網站地圖如何制作 文章出處:淮南智誠網絡公司    網站責任編輯:     作者:     人氣:1059    發表時間:2013-10-20

今天智誠網絡小編告訴您如何制作網站地圖,網站地圖就是網站的頁面路徑。網站地圖在網站優化中起著重要作用,網站地圖分XML地圖和HTML地圖今天小編告訴您如何制作XML地圖
代碼如下

<%

'修改下面的三個設置參數,網址,物理目錄和虛擬目錄
session("server")="http://www.fqol.net/
vDir = "/"
phisicalDir="D:\help8_cn\WwwRoot\"

'時區設置,這里設置本地時間同服務器時間的差值
utcOffset=1


set objfso = CreateObject("Scripting.FileSystemObject")
root = Server.MapPath(vDir)

response.ContentType = "text/xml"
response.write "<?xml version='1.0' encoding='UTF-8'?>"
response.write "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>"

Set objFolder = objFSO.GetFolder(root)
Set colFiles = objFolder.Files
For Each objFile In colFiles
 response.write getfilelink(objFile.Path,objfile.dateLastModified)
Next
ShowSubFolders(objFolder)

response.write "</urlset>"
set fso = nothing


Sub ShowSubFolders(objFolder)
 Set colFolders = objFolder.SubFolders
 For Each objSubFolder In colFolders
  if folderpermission(objSubFolder.Path) then
   response.write getfilelink(objSubFolder.Path,objSubFolder.dateLastModified)
   Set colFiles = objSubFolder.Files
   For Each objFile In colFiles
    response.write getfilelink(objFile.Path,objFile.dateLastModified)
   Next
   ShowSubFolders(objSubFolder)
  end if
 Next
End Sub


Function getfilelink(file,data)
 file=replace(file,phisicalDir,"")
 file=replace(file,"\","/")
 If FileExtensionIsBad(file) then Exit Function
 If FileNameIsBad(file) then Exit Function
 filelmdate=iso8601date(data,utcOffset)

 getfilelink = "<url><loc>"&server.htmlencode(session("server")&file)&"</loc><lastmod>"&filelmdate&"</lastmod><priority>1.0</priority></url>"
 session("URLS")=session("URLS")+1
 Response.Flush
End Function


Function Folderpermission(pathName)
 '設置不想包括在sitemaps里的目錄
 PathExclusion=Array("\temp","\_vti_cnf","\_vti_pvt","\_vti_log","\cgi-bin","\admin","\bak","\images")
 Folderpermission =True
 for each PathExcluded in PathExclusion
  if instr(ucase(pathName),ucase(PathExcluded))>0 then
   Folderpermission = False
   exit for
  end if
 next
End Function


Function FileExtensionIsBad(sFileName)
 Dim sFileExtension, bFileExtensionIsValid, sFileExt
 'http://www.googleguide.com/file_type.html
 Extensions = Array("png","gif","jpg","zip","pdf","ps","html","htm","asp","wk1","wk2","wk3","wk4","wk5","wki","wks","wku","lwp","mw","xls","ppt","doc","wks","wps","wdb","wri","rtf","ans","txt")

 if len(trim(sFileName)) = 0 then
  FileExtensionIsBad = true
  Exit Function
 end if

 sFileExtension = right(sFileName, len(sFileName) - instrrev(sFileName, "."))
 bFileExtensionIsValid = false 'assume extension is bad
 for each sFileExt in extensions
  if ucase(sFileExt) = ucase(sFileExtension) then
   bFileExtensionIsValid = True
   exit for
  end if
 next
 FileExtensionIsBad = not bFileExtensionIsValid
End Function

Function FileNameIsBad(sFileName)
        if len(trim(sFileName)) = 0 then
                FileNameIsBad = true
                Exit Function
        end if
        Filename = Array("/alive.asp","/404.asp","/500.asp","/sitemap_gen.asp")
        FileNameNumber = ubound(Filename)
        for i=0 to FileNameNumber
                if Filename(i) = sFileName then
                        FileNameIsBad = True
                end if
        next
End Function

Function iso8601date(dLocal,utcOffset)
 Dim d
 ' 根據時區設置來轉換本地時間
 d = DateAdd("H",-1 * utcOffset,dLocal)

 ' compose the date
 iso8601date = Year(d) & "-" & Right("0" & Month(d),2) & "-" & Right("0" & Day(d),2) & "T" & _
  Right("0" & Hour(d),2) & ":" & Right("0" & Minute(d),2) & ":" & Right("0" & Second(d),2) & "Z"
End Function
%>

 

想和他們一樣成功嗎?
此文關鍵詞:
域名查詢

    國家域名處理投訴中心
    010-58813000
    Email:[email protected]
Copyright © 2007 - 2018 版權所有 淮南智誠互動網絡科技有限公司
皖ICP備09027578號 聯系我們
塞维利亚地图 恒大线上娱乐网址 广东11选5分析软件 天津时时自由的百科 bet338高级娱乐群 大赢家投注单打印系统 大小单双技巧 网上三分快三大小单双技巧 北京老时时 河北时时网站 扑克牌21点技巧 捕鱼达人2有卡片的版本下载 pk10长期稳赚6码