网站404页面怎么做

  • 2,769 views

网站404页面怎么做?

404页面的目的是:告诉浏览者其所请求的页面不存在或链接错误,同时引导用户使用网站其他页面而不是关闭窗口离开。

很多开源系统包括CMS系统、Blog系统等不提供404页面或提供的404页面并未达到SEO的要求,这让网站的权威性大打折扣。

404页面该达到怎么样的效果才符合SEO要求?

搜索引擎通过HTTP状态码来识别网页的状态。当搜索引擎获得了一个错误链接时,网站应该返回404状态码,告诉搜索引擎放弃对该链接的索引。而如果返回200或302状态码,搜索引擎就会为该链接建立索引,这导致大量不同的链接指向了相同的网页内容。结果是,搜索引擎对该网站的信任度大幅降低。——很多网站存在这个问题:404页面返回的是200或302状态码而不是404状态码。

正确建立404页面的方法是:(仅适合Apache服务器)

在.htaccess 文件中加入代码: ErrorDocument 404 /Error.html
建立一个简单的html404页面命名 Error.html
把 Error.html放置在网站根目录
如果碰到困难,参考本站:错误网页 和 .htaccess文件内容如下:

##

# if you want to use mod_rewrite, set this 'On'
RewriteEngine On

# the path to your site installation
RewriteBase /

# Maintenance Section - Uncomment the lines below according to your need
# Write below your client IP address (e.g.: 127.0.0.1)
# if you need to keep your web access during maintenance
#RewriteCond %{REMOTE_ADDR}          !^127.0.0.1$
# Choose your way of closing the access to PMF:
# a. you can simply forbid access (HTTP 403 Error)
#RewriteRule ^(.*)$                  underMaintenance.htm [F,L]
# b. return the user an explanation
#RewriteRule ^(.*)$                  underMaintenance.htm [L]

# url canonicalization
RewriteCond %{http_host} ^seowhy.com [NC]
RewriteRule ^(.*)$ http://www.seowhy.com/$1 [L,R=301]

# show all categories
RewriteCond %{REQUEST_URI}          showcat\.html$ [NC]
RewriteRule ^(.*)$                  index.php?action=show [L,QSA]

# the search page
RewriteCond %{REQUEST_URI}          search\.html$ [NC]
RewriteRule ^(.*)$                  index.php?action=search [L,QSA]

# the add content page
RewriteCond %{REQUEST_URI}          addcontent\.html$ [NC]
RewriteRule ^(.*)$                  index.php?action=add [L,QSA]

# the ask question page
RewriteCond %{REQUEST_URI}          ask\.html$ [NC]
RewriteRule ^(.*)$                  index.php?action=ask [L,QSA]

# the open questions page
RewriteCond %{REQUEST_URI}          open\.html$ [NC]
RewriteRule ^(.*)$                  index.php?action=open [L,QSA]

# the help page
RewriteCond %{REQUEST_URI}          help\.html$ [NC]
RewriteRule ^(.*)$                  index.php?action=help [L,QSA]

# the contact page
RewriteCond %{REQUEST_URI}          contact\.html$ [NC]
RewriteRule ^(.*)$                  index.php?action=contact [L,QSA]

# a page with a record
RewriteCond %{REQUEST_URI}          ([0-9]+)_([0-9]+)_([a-z\-]+)\.html$ [NC]
RewriteRule ^(.*)_(.*)_(.*)\.html$  index.php?action=artikel&cat=$1&id=$2&artlang=$3 [L,QSA]

# a category page
RewriteCond %{REQUEST_URI}              category([0-9]+)\.html$ [NC]
RewriteRule ^category(.*)\.html$        index.php?action=show&cat=$1 [L,QSA]

# a category page with page count
RewriteCond %{REQUEST_URI}              category([0-9]+)_([0-9]+)\.html$ [NC]
RewriteRule ^category(.*)_(.*)\.html$   index.php?action=show&cat=$1&seite=$2 [L,QSA]

# start page
RewriteRule index.html$ index.php [PT]

# sitemap
RewriteCond %{REQUEST_URI}              sitemap-([a-zA-Z0-9漩周遌*)_([a-z\-]+)\.html$ [NC]
RewriteRule ^sitemap-(.*)_(.*)\.html$   index.php?action=sitemap&letter=$1&lang=$2 [L,QSA]

# a solution id page
RewriteCond %{REQUEST_URI}              solution_id_([0-9]+)\.html$ [NC]
RewriteRule ^solution_id_(.*)\.html$    index.php?solution_id=$1 [L,QSA]

# 404 page
ErrorDocument 404 /404.html

注意:

不要将404错误直接转向到网站首页,这将导致首页不被收录;
/Error.html 前面不要带主域名,否则返回的状态码是302或200状态码。

weinxin
我的微信
分享SEO优化、SEM营销、新媒体知识,交流营销运营经验,提供网站制作、SEO、竞价托管和公众号代运营服务。
王发利
  • 本文由 发表于 2014 年 2 月 6 日
  • 转载请务必保留本文链接:http://wangfali.com/seo/803.html
Tag标签页面如何优化?Tag标签是什么? SEO知识

Tag标签页面如何优化?Tag标签是什么?

Tag标签页面如何优化?Tag标签是什么? 在网站优化中有一个优化利器,那就是标签的优化,通常我们也叫做tag优化。通过大批量的铺设tag页面,再通过合理的关键词布局和优化方法,我们可以做出大量的关键...
什么事千人千面?详解百度千人千面算法! SEO知识

什么事千人千面?详解百度千人千面算法!

什么事千人千面?详解百度千人千面算法!在2020年的时候,百度搜索引擎官方开始上线千人千面算法,其实这个千人千面算法就是根据个人的喜好来展现搜索结果,这算法涉及到了个人的搜索习惯、个人的爱好、个人感兴...
SEO行业名词解释大全 SEO知识

SEO行业名词解释大全

优化网站做SEO,了解seo行业名词必看seo名词解释,明白seo行业、读懂seo名词解释能够帮助我们更好地工作和指导网站优化。在做SEO前先搞清楚这些seo行业名词,我想是很有必要的,今天借助王发利...
B2B网站上Ttitle应该怎么写? SEO知识

B2B网站上Ttitle应该怎么写?

B2B网站上Ttitle应该怎么写?很多中小企业卖家,选择b2b平台做关键词优化在当前来说,是省钱又有效的方法。因为,可以通过利用b2b网站的高权优势,帮助企业快速获得关键词排名和流量,从而提升产品销...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: