sitemap制作
http://teachmyself.blog.163.com/blog/static/18881422920119895435272/
sitemap.xml是一种站点地图协议,此协议文件基于早期的robots.txt文件协议,并有所升级。向搜索引擎中提交了sitemap.xml的 网站将更有利于搜索引擎网页爬行机器人的爬行索引,这样将提高索引网站内容的效率和准确度。
一共有六个标签,changefreq:页面内容更新频率;
- lastmod:页面最后修改时间;
- loc:页面永久链接地址;
- priority:相对于其他页面的优先权(这个标签可以不使用);
- url:相对于前 4个标签的父标签;
- urlset:相对于前5个标签的父标签。
你可以向搜索引擎提供多个Sitemap文件,但提供的每个Sitemap文件包括的网址不得超过50,000 个,并且未压缩时不能大于10MB 。
- 向Google提交网站地图Sitemap: 通过网址http://www.google.com/webmasters管理提交;
- 向Yahoo!提交网站地图Sitemap: 通过网址http://siteexplorer.search.yahoo.com管理提交;
- 向MSN提交网站地图Sitemap: 用URL直接提交:http://api.moreover.com/ping?u=http%3A//your.domainname /sitemap.xml。这是向MSN直接提交网站地图的后门URL。注意”:”被%3A替换掉。
- 向ASK提交网站地图Sitemap: 直接提交。http://submissions.ask.com/ping?sitemap=http%3A//your.domainname/sitemap.xml。注意”:”被%3A替换掉。
sitemap.xml文件格式如下:

<?xml version=”1.0″ encoding=”UTF-8″ ?>
<urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9“>
<url>
<loc>http://www.grzz.com.cn/</loc>
<lastmod>2009-04-27</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://www.grzz.com.cn/index.html</loc>
<lastmod>2009-04-27</lastmod>
<changefreq>weekly</changefreq>
</url>
</urlset>

那怎么制作sitemap.xml。最笨的方法就是按照这六个标签的规则,自己手写了。
如 果网站的页面太多了,这个就会变成了一个超级郁闷的体力劳动。于是就有不少sitemap.xml的生成工具出现了,但是现在大部分的 sitemap.xml生成工具都是在客户端输入网址,让工具在网站自行寻找链接生成,这样的模式,Rookie感觉效率比较低,而且没有办法对生成链接 做控制。终于在网上找到了一个比较好的方法,适用于将内容生成静态页面的网站。有人将生成sitemap.xml的功能,写成了asp和php的页面,在 页面上可以控制需要生成哪些链接。按照你的需要修改页面后,再把页面上传到你的网站空间,访问这个页面就是你所需要的sitemap.xml文件。然后就 保存成为xml文件格式,再上传到你的空间,再将链接提交给支持sitemap.xml的搜索引擎。
Asp文件,将蓝色代码复制到文本文件,再保存成sitemap.asp,修改相关设置后,上传到服务器,访问即可

<%
session(”server”)=”http://www.grzz.com.cn“ ‘将此http://www.grzz.com.cn改成你的域名
vDir = “/” ‘制作SiteMap的目录
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.sitemaps.org/schemas/sitemap/0.9′>” 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,datafile)
‘changefreq更改参数:always, hourly, daily, weekly, monthly, yearly , never
file=replace(file,root,”")
file=replace(file,”\”,”/”)
If FileExtensionIsBad(file) then Exit Function
if month(datafile)<10 then filedatem=”0″
if day(datafile)<10 then filedated=”0″
filedate=year(datafile)&”-”&filedatem&month(datafile)&”-”&filedated&day(datafile)
getfilelink = “<url><loc>”&server.htmlencode(session(”server”)&vDir&file)&”</loc><lastmod>”&filedate&”</lastmod><changefreq>weekly</changefreq></url>”
Response.Flush
End Function
Function Folderpermission(pathName) ’需要过滤的目录(不列在SiteMap里面)
PathExclusion=Array(”\ad”,”\admin”,”\aspnet_client”,”\Count”,”\data”,”\Inc”,”\upload”,”\template”)
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
Extensions = Array(”html”)
‘设置列表的文件名,扩展名不在其中的话SiteMap则不会收录该扩展名的文件 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
%>

Php文件,将红色代码复制到文本文件,再保存成sitemap.php,修改相关设置后,上传到服务器,访问即可

<?php
header(’Content-type: application/xml; charset=”GB2312″‘,true);
?>
<?php
$website = “http://www.grzz.com.cn“; /* 将此http://www.grzz.com.cn改成你的域名 */
$page_root = “/”; /*更改成你网站的目录地址*/
/* changefreq可自行设置 */
$changefreq = “weekly”; //”always”, “hourly”, “daily”, “weekly”, “monthly”, “yearly” and “never”.
/* 修改时间 */
$last_modification = date(”Y-m-d\TH:i:s”) . substr(date(”O”),0,3) . “:” . substr(date(”O”),3); /* 需要生成的目录 */
$allow_dir[] = “web”; /* 需要过滤的目录(不列在SiteMap里面) */
$disallow_dir[] = “admin”;
$disallow_dir[] = “_notes”; /* 设置列表的文件名,扩展名不在其中的话SiteMap则不会收录该扩展名的文件 */
$disallow_file[] = “.inc”;
$disallow_file[] = “.old”;
$disallow_file[] = “.save”;
$disallow_file[] = “.txt”;
$disallow_file[] = “.js”;
$disallow_file[] = “~”;
$disallow_file[] = “.LCK”;
$disallow_file[] = “.zip”;
$disallow_file[] = “.ZIP”;
$disallow_file[] = “.CSV”;
$disallow_file[] = “.csv”;
$disallow_file[] = “.css”;
$disallow_file[] = “.class”;
$disallow_file[] = “.jar”;
$disallow_file[] = “.mno”;
$disallow_file[] = “.bak”;
$disallow_file[] = “.lck”;
$disallow_file[] = “.BAK”; /* simple compare function: equals */
function ar_contains($key, $array) {
foreach ($array as $val) {
if ($key == $val) {
return true;
}
}
return false;
} /* better compare function: contains */
function fl_contains($key, $array) {
foreach ($array as $val) {
$pos = strpos($key, $val);
if ($pos === FALSE) continue;
return true;
}
return false;
} /* this function changes a substring($old_offset) of each array element to $offset */
function changeOffset($array, $old_offset, $offset) {
$res = array();
foreach ($array as $val) {
$res[] = str_replace($old_offset, $offset, $val);
}
return $res;
} /* this walks recursivly through all directories starting at page_root and
adds all files that fits the filter criterias */
// taken from Lasse Dalegaard,
function getFiles($directory, $directory_orig = “”, $directory_offset=”") {
global $disallow_dir, $disallow_file, $allow_dir;
if ($directory_orig == “”) $directory_orig = $directory; if($dir = opendir($directory)) {
// Create an array for all files found
$tmp = Array(); // Add the files
while($file = readdir($dir)) {
// Make sure the file exists
if($file != “.” && $file != “..” && $file[0] != ‘.’ ) {
// If it’s a directiry, list all files within it
//echo “point1<br>”;
if(is_dir($directory . “/” . $file)) {
//echo “point2<br>”;
$disallowed_abs = fl_contains($directory.”/”.$file, $disallow_dir); // handle directories with pathes
$disallowed = ar_contains($file, $disallow_dir); // handle directories only without pathes
$allowed_abs = fl_contains($directory.”/”.$file, $allow_dir);
$allowed = ar_contains($file, $allow_dir);
if ($disallowed || $disallowed_abs) continue;
if ($allowed_abs || $allowed){
$tmp2 = changeOffset(getFiles($directory . “/” . $file, $directory_orig, $directory_offset), $directory_orig, $directory_offset);
if(is_array($tmp2)) {
$tmp = array_merge($tmp, $tmp2);
}
}
} else { // files
if (fl_contains($file, $disallow_file)) continue;
array_push($tmp, str_replace($directory_orig, $directory_offset, $directory.”/”.$file));
}
}
}
// Finish off the function
closedir($dir);
return $tmp;
}
} $a = getFiles($page_root); echo ‘<?xml version=”1.0″ encoding=”UTF-8″?>’;
?>
<urlset xmlns=’http://www.sitemaps.org/schemas/sitemap/0.9′>
<? foreach ($a as $file) { ?>
<url>
<loc><? echo utf8_encode($website.$file); ?></loc>
<lastmod><? echo utf8_encode(date(”Y-m-d\TH:i:s”, filectime($page_root.$file)). substr(date(”O”),0,3) . “:” . substr(date(”O”),3));?></lastmod>
<changefreq><? echo utf8_encode($changefreq); ?></changefreq>
</url>
<?}?>
</urlset>
sitemap制作的更多相关文章
- 分享一个在线生成站点地图SiteMap制作工具
站点地图SiteMap的好处是很大的,对Seo很有好处,能够更方便.迅速的让搜索引擎收录.WordPress 有不少生成Google Sitemap 的工具,但是有些只是针对WordPress的系统的 ...
- 织梦dedecms中html和xml格式的网站地图sitemap制作方法
sitemap是网站上各网页的列表.创建并提交sitemap有助于百度(Google)发现并了解您网站上的所有网页,包括百度通过传统抓取方式可能找不到的网页.还可以使用sitemap提供有关你网站的其 ...
- 织梦 百度sitemap制作教程
一.新建一个sitemap.htm模板 登录dedecms后台,选择[模板]-[模板管理]-[默认模板管理] 点击最下面的[新建模板]新建一个模板,并复制下面这段代码进去(将代码中的域名改为自己的): ...
- sitemap怎么制作才适合蜘蛛抓取?
网站sitemap制作格式与要求 1.sitemap格式说明 <?xml version="1.0" encoding="utf-8"?> < ...
- Axure原型制作规范
一. 名词定义: Sitemap 导航图 Widgets 组件 Master 库 Label 控件名 Interactions 交互动作 Annotations 注释 Location and siz ...
- 25个站长必备的SEO优化工具
搜索引擎抓取内容模拟器 可以模拟蜘蛛抓取指定网页,包括Text.Link.Keywords及Description信息等.http://www.webconfs.com/search-engine-s ...
- 整站死链接检测与查询工具 Xenu(可以用来制作sitemap)
http://www.wocaoseo.com/thread-286-1-1.html 很多新手朋友们都会去找一些工具来检查网站死链接,这里给大家分享一款非常好用的检查网站死链接的工具xenu,大家可 ...
- SiteMap 提交,并使用正确的方式提交给搜索引擎
原创Sitemap收录介绍 对于网站中原创内容的网页url,站长可以将其制作成标准的Sitemap(站点地图)文件. 站长提交Sitemap文件后,好搜会使用Sitemap中的内容来了解网站结构等信息 ...
- 只需三步 快速完善网站Sitemap
越来越多的SEOer把优化的重点放在了站内优化上,细心的朋友应该查看一些前辈的robots.txt的时候不难发现,他们的robots中都加 入了一句Sitemap: http://www.dewang ...
随机推荐
- DOM操作-主动触发按钮的单击事件
代码: ———————————————————————————————— <script> function fireBtnClick(){ var myBtn ...
- @Value 注解获取properties值
转自:使用Spring 3的@value简化配置文件的读取 Spring 3支持@value注解的方式获取properties文件中的配置值,大简化了读取配置文件的代码. 1.在application ...
- @Autowired 和 @Resource
转自:Spring中@Autowired注解.@Resource注解的区别 Spring不但支持自己定义的@Autowired注解,还支持几个由JSR-250规范定义的注解,它们分别是@Resourc ...
- 利用朴素贝叶斯算法进行分类-Java代码实现
http://www.crocro.cn/post/286.html 利用朴素贝叶斯算法进行分类-Java代码实现 鳄鱼 3个月前 (12-14) 分类:机器学习 阅读(44) 评论(0) ...
- hdu_5029_relief grain(树链剖分)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5029 题意:给你一个树,然后给你两点,将这两点之间的点涂上颜色,问涂色最多的那个颜色是什么,如果数量相 ...
- 怎么利用GitHub
我们一直用GitHub作为 免费的远程仓库,如果是个人的开源项目,放到GitHub上完全没有问题,其实GitHub就是一个开源协作社区,既可以让 别人参与你的开源项目,也可以参与别人的开源项目,在Gi ...
- 获取IP地址bash[转载]
ipaddr=`/sbin/ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d : -f2 | awk '{print $1}'`
- Nginx配置IP白名单和黑名单
白名单设置,访问根目录 location / { allow 123.34.22.155; allow ; deny all; } 黑名单设置,访问根目录 location / { deny 123. ...
- 使用composer安装laravel
跟具官方文档说:Laravel utilizes Composer to manage its dependencies. So, before using Laravel, you will nee ...
- 关于hasnextLine()方法的一些理解
以前对于hasnextline的理解就是 :判断是否有下一个值 今天发现了个特例,它竟然是个阻塞式的方法 看下面一个案例 这是服务器 package Service; import java.io.I ...