网站的301重定向和404页面对网站优化来说有着至关重要的作用,我们不能将其忽略!
301重定向(301 redirect)又叫301代表永久性转移(Permanently Moved),将各种网络请求重新定个方向转到其它位置,是网页更改地址后对搜索引擎友好的最好方法,只要不是暂时搬移的情况,都建议使用301来做转址。
1、将不带www的网址跳转到带www的网址:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^aaaa.com [NC]
RewriteRule ^(.*)$ http://www.aaaa.com/$1 [L,R=301]
将上面代码中的aaaa换成你网站的网址,让后复制到记事本,再将记事本重命名为.htaccess上传到根目录,ok完成!
2、页面中的301跳转
eg:将tags.php跳转到tags.html,这也是一个标签的静态化,这个对网站优化也是很有好处的!
RewriteEngine on
RewriteRule ^tags.php(.*)$ /tags.html$1 [R=301,L]
同样是将扇面代码复制,以.htaccess文件形式上传的根目录,完成!
3、apache设置404页面:
<Files *>
Options -Indexes
</Files>
ErrorDocument 404 /404/index.html
ErrorDocument 403 /404/index.html
附带了一个403页面设置,其实是一样的 ,将代码复制,如上的操作,所有工作完成!