通过301的重定向我们可以更好的URL网址标准化,武汉SEO在学习SEO过程中给大家整理了网上的一些301重定向方法,希望对大家有用。
1.apache服务器一般采用是“mod_rewrite”技术
哪么你只要在.htaccess文件中增加301重定向指令,如:
RewriteEngine on
RewriteRule ^(.*)$ http://www.33230.com$1 [R=301,L]
2. Unix网络服务器的用户
可以通过此指令让搜索引擎的蜘蛛清楚你的站点文件已不在此地址下。这是较为常用的办法。
形如:Redirect 301 / http://www.33230.com
3.绑定/本地DNS
如果你有对本地DNS记录进行编辑修改的权限,哪么你只要添加一个记录就可以解决此问题。如果没有权限,可要求网站托管商对DNS服务器进行相应设置。
DNS服务器的设置
如果在将www.33230.org指向到www.33230.com,哪么只需在DNS服务中应增加一条别名记录,可写成:blog IN CNAME www.33230.com。
如果你有大量的虚拟域名,哪么可写成:* IN CNAME www.33230.com.
这样就可将所有没设以33230.org结尾的记录全部重定向到www.33230.com上。
4.在服务器软件的系统管理员配置区完成301重定向
一般适用于使用Window网络服务器的用户
5.用ASP/PHP实现301重定向:
ASP:
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”http://www.xiaohan86.com”
Response.End
PHP:
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location:http://www.xiaohan86.com”);
exit();
备注:把代码加到相关页面就可以了。
下面是我收集的一些关于301重定向代码
1、ASP下的301转向代码
<%@ %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, “http://www.33230.com/articles/301/”
%>
3、ASP.Net下的301转向代码
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(”Location”,”http://www.33230.com/articles/301/“);
}
</script>
4、PHP下的301转向代码
header(”HTTP/1.1 301 Moved Permanently”);
header(”Location: http://www.33230.com/articles/301/”);
exit();
5、CGI Perl下的301转向代码
$q = new CGI;
print $q->redirect(”http://www.33230.com/”);
6、JSP下的301转向代码
<%
response.setStatus(301);
response.setHeader( “Location”, “http://www.33230.com/” );
response.setHeader( “Connection”, “close” );
%>
7、Apache下301转向代码
新建.htaccess文件,输入下列内容(需要开启mod_rewrite):
1)将不带WWW的域名转向到带WWW的域名下
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^lesishu.cn [NC]
RewriteRule ^(.*)$ http://www.33230.com/$1 [L,R=301]
2)重定向到新域名
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.33230.com/$1 [L,R=301]
3)使用正则进行301转向,实现伪静态
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^news-(.+)\.html$ news.php?id=$1
将news.php?id=123这样的地址转向到news-123.html

Leave a Reply
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>