- <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错误页面的重定向到博客的主页。
- 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。
- 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。
- 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/搜索/搜索关键字”的搜索结果永久改写,最终其比默认搜索永久性的更好,从而提高搜索引擎优化。
- 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等等。