1. 404重定向页面 < IfModule mod_alias.c > RedirectMatch 301 ^/search/$ http://your-site.com/ RedirectMatch 301 ^/tag/$ http://your-site.com/ RedirectMatch 301 ^/category/$ http://your-site.com/ < /IfModule > 404错误页面是这些页面产生当没有网页内容所指定的。坏的部分是,404页,404页减少你的博客的Pagerank使你的站点排名无效。所以,我们将致力于改善SEO是利用WordPress Hack 404错误页面的重定向到博客的主页。2.自动从URL中删除停止词

1. 404重定向页面

5个代码片段改进SEO优化排名(seo代码优化有哪些方法)  5个 SEO优化 代码 使用技巧 排名 新闻资讯 第1张

< IfModule mod_alias.c >
RedirectMatch 301 ^/search/$ http://your-site.com/
RedirectMatch 301 ^/tag/$ http://your-site.com/
RedirectMatch 301 ^/category/$ http://your-site.com/
< /IfModule >

404过错页面是这些页面发生当没有网页内容所指定的。坏的部分是,404页,404页削减你的博客的Pagerank使你的站点排名无效。所以,咱们将致力于改进SEO是运用WordPress Hack 404过错页面的重定向到博客的主页。

2.主动从URL中删去中止词

add_filter('sanitize_title', 'remove_short_words');
function remove_short_words($slug) {
if (!is_admin()) return $slug;
$slug = explode('-', $slug);
foreach ($slug as $k => $word) {
if (strlen($word) < 3) {
unset($slug[$k]);
}
}
return implode('-', $slug);
}

当你写博客文章的标题在WordPress,依据标题永久链接调整你写的。人们认为咱们不应该中止的话,像对,,等的博客文章的永久链接。它进步了查找引擎优化,还有助于希望从URL的内容只。所以,为了使唯命是从主动完结,运用代码片段来主动删去stop单词从永久链接来进步SEO。

3.杰出关键字在查找成果

function wps_highlight_results($text){
if(is_search()){
$sr = get_query_var('s');
$keys = explode(" ",$sr);
$text = preg_replace('/('.implode('|', $keys) .')/iu', '<strong>'.$sr.'</strong>', $text);
}
return $text;
}
add_filter('the_excerpt', 'wps_highlight_results');
add_filter('the_title', 'wps_highlight_results');

运用此代码段杰出显现查找词在你的博客查找成果the_excerpt和the_title。

4.改写查找成果的永久链接

function search_url_rewrite_rule() {
if ( is_search() && !empty($_GET['s'])) {
wp_redirect(home_url("/search/") . urlencode(get_query_var('s')));
exit();
}
}
add_action('template_redirect', 'search_url_rewrite_rule');

这个片段能够协助你像“yourblog.com/查找/查找关键字”的查找成果永久改写,终究其比默许查找永久性的更好,然后进步查找引擎优化。

5.谷歌机器人的制止目录

User-agent: Googlebot
Allow: /?display=wide
Disallow: /wp-content/
Disallow: /trackback/
Disallow: /wp-admin/
Disallow: /feed/
Disallow: /index.php
Disallow: /*?
Disallow: /*.js$
Disallow: /*.inc$
Disallow: /*.css$
Disallow: */feed/
Disallow: */trackback/
Disallow: /link.php
Disallow: /gallery2
Disallow: /gallery2/
Disallow: /refer/
User-agent: Googlebot-Image
Disallow: /wp-includes/
User-agent: Mediapartners-Google*
Disallow:

运用这段代码片段在你的机器人,txt文件来避免Gogole机器人能像wp-content指数不希望的目录,wp-includes等等。

转载请说明出处
知优网 » 5个代码片段改进SEO优化排名(seo代码优化有哪些方法)

发表评论

您需要后才能发表评论