wordpress优化头部 去掉版权等信息 wordpress去掉generator

wordpress优化头部 去掉版权等信息 wordpress去掉generator,第1张

wordpress="superseo">ss优化头部去掉版权等信息wordpress去掉generator

一般看一下就应该明白是什么意思了。这将确保html头中没有其他代码。去掉wordpress的生成器标志

wordpress在默认设置状况下,头部会出現许多平常用不上的html代码,例如:

复制代码代码以下:
<linkrel="alternate"type="application/rssxml"title="RSS2.0-allposts"href="http://blog.jb51.net/feed"/>
<linkrel="alternate"type="application/rssxml"title="RSS2.0-allcomments"href="http://blog.jb51.net/comments/feed"/>
<linkrel="pingback"href="http://blog.jb51.net/xmlrpc.php"/>
<linkrel="EditURI"type="application/rsdxml"title="RSD"href="http://blog.jb51.net/xmlrpc.php?rsd"/>
<linkrel="wlwmanifest"type="application/wlwmanifestxml"href="http://blog.jb51.net/wp-includes/wlwmanifest.xml"/>
<linkrel='index'title='SBMStoneCrusherMachine|GrindingMill'href='http://blog.jb51.net'/>
<metaname="generator"content="WordPress3.4"/>

上边的标识中,例如generator,可能曝露你的博客系统用的是哪一个版本号,这一信息内容泄露有时候会对blog的安全性造成一定的危害。另外,也并不一定用那么多标识。
除掉一些无需的标识,在网上有方式说主题目录下的functions.php里提升下列代码:

复制代码代码以下:
functionwpbeginner_remove_version(){
return&rdquo;;
}
add_filter('the_generator','wpbeginner_remove_version');//wordpress的版本信息
remove_action('wp_head','feed_links',2);//包括文章内容和评价的feed。
remove_action('wp_head','index_rel_link');//当今文章内容的数据库索引。
remove_action('wp_head','wlwmanifest_link');//外界在线编辑器如windowslivewriter务必。
remove_action('wp_head','feed_links_extra',3);//附加的feed,比如category,tag页。
remove_action('wp_head','start_post_rel_link',10,0);//刚开始篇
remove_action('wp_head','parent_post_rel_link',10,0);//父篇
remove_action('wp_head','adjacent_posts_rel_link',10,0);//上、续篇.

检测了下,能够除掉wordpress的generator,一些代码還是去不掉,但也有另个一个更立即的方式。
便是在wodpress文件目录下改动wp-includes文件目录下的default-filters.php,大约在180几行:

复制代码代码以下:
//add_action('wp_head','feed_links',2);
//add_action('wp_head','feed_links_extra',3);
//add_action('wp_head','rsd_link');
//add_action('wp_head','wlwmanifest_link');
//add_action('wp_head','index_rel_link');
//add_action('wp_head','parent_post_rel_link',10,0);
//add_action('wp_head','start_post_rel_link',10,0);
//add_action('wp_head','adjacent_posts_rel_link_wp_head',10,0);
add_action('wp_head','locale_stylesheet');
add_action('publish_future_post','check_and_publish_future_post',10,1);
add_action('wp_head','noindex',1);
add_action('wp_head','wp_print_styles',8);
add_action('wp_head','wp_print_head_scripts',9);
//add_action('wp_head','wp_generator');
//add_action('wp_head','rel_canonical');
add_action('wp_footer','wp_print_footer_scripts');
//add_action('wp_head','wp_shortlink_wp_head',10,0);
add_action('template_redirect','wp_shortlink_header',11,0);

不用的立即//注解掉就可以了。一般看下就应当明白是什么意思的。那样能够确保html头部已不有其他的代码了。除掉了wordpress的generator标识。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/772586.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-03
下一篇 2022-05-03

发表评论

登录后才能评论

评论列表(0条)

保存