怎么做301重定向
2011-03-19 at 05:38 下午 宽宽非常经典的内容,经常有新人问,省的他们翻搜索引擎了。
1、IIS下301设置
Internet信息服务管理器 -> 虚拟目录 -> 重定向到URL,输入需要转向的目标URL,并选择"资源的永久重定向"。
2、ASP下的301转向代码
- <%@ Language=VBScript %>
- <%
- Response.Status=”301 Moved Permanently”
- Response.AddHeader “Location”, “http://www.kuankuan.net/2011/03/19/how-to-do-a-301-redirect/”
- %>
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.kuankuan.net/2011/03/19/how-to-do-a-301-redirect/“);
- }
- </script>
- ?>
4、PHP下的301转向代码
- header(”HTTP/1.1 301 Moved Permanently”);
- header(”Location: http://www.kuankuan.net/2011/03/19/how-to-do-a-301-redirect/”);
- exit();
- ?>
5、CGI Perl下的301转向代码
- $q = new CGI;
- print $q->redirect(”http://www.kuankuan.net/”);
- ?>
6、JSP下的301转向代码
- <%
- response.setStatus(301);
- response.setHeader( “Location”, “http://www.kuankuan.net/” );
- response.setHeader( “Connection”, “close” );
- %>
- ?>
7、Apache下301转向代码
新建.htaccess文件,输入下列内容(需要开启mod_rewrite):
1)将不带WWW的域名转向到带WWW的域名下
- Options +FollowSymLinks
- RewriteEngine on
- RewriteCond %{HTTP_HOST} ^kuankuan.cn [NC]
- RewriteRule ^(.*)$ http://www.kuankuan.net/$1 [L,R=301]
2)重定向到新域名
- Options +FollowSymLinks
- RewriteEngine on
- RewriteRule ^(.*)$ http://www.kuankuan.net/$1 [L,R=301]
3)使用正则进行301转向,实现伪静态
- Options +FollowSymLinks
- RewriteEngine on
- RewriteRule ^news-(.+)\.html$ news.php?id=$1
将news.php?id=123这样的地址转向到news-123.html
8、Apache下vhosts.conf中配置301转向
为实现URL规范化,SEO通常将不带WWW的域名转向到带WWW域名,vhosts.conf中配置为:
- <VirtualHost *:80>
- ServerName www.kuankuan.cn
- DocumentRoot /home/kuankuan
- </VirtualHost>
- <VirtualHost *:80>
- ServerName kuankuan.cn
- RedirectMatch permanent ^/(.*) http://www.kuankuan.net/$1
- </VirtualHost>
Apache下除了以上2种方法,还有其他配置方法和可选参数,建议阅读Apache文档。
301转向情况检测
http://www.seoconsultants.com/tools/headers.asp
http://www.internetofficer.com/seo-tool/redirect-check/
Buy@Cheap.Abana” rel=”nofollow”>..…
Buygeneric pills…
Purchase@Abilify.Online” rel=”nofollow”>……
Buywithout prescription…
Buy@Generic.Abilify.5mg.10mg.15mg.20mg.30mg” rel=”nofollow”>……
Buywithout prescription…
Purchase@Discount.Acai” rel=”nofollow”>..…
Buywithout prescription…
Buy@Acai.Without.Prescription” rel=”nofollow”>……
Buynow…
Buy@Cheap.Coral.Calcium” rel=”nofollow”>.…
Buynow it…
Buy@Cheap.Coral.Calcium” rel=”nofollow”>……
Buygeneric meds…
Cheap@Coral.Calcium.Online” rel=”nofollow”>..…
Buygeneric drugs…
Order@Discount.Abana” rel=”nofollow”>..…
Buygeneric meds…
Buy@Abilify.Online” rel=”nofollow”>..…
Buynow it…
Buy@Cheap.Abilify” rel=”nofollow”>……
Buygeneric pills…
Cheap@Abilify.Without.Prescription” rel=”nofollow”>..…
Buyno prescription…
Order@Accupril.Online” rel=”nofollow”>.…
Buygeneric drugs…
Buy@Discount.Accutane” rel=”nofollow”>.…
Buynow it…
.…
Buygeneric drugs…
Order@Cheap.Actos” rel=”nofollow”>.…
Buygeneric drugs zfk…
Actos@15mg.30mg.Without.Prescription” rel=”nofollow”>..…
Buygeneric meds qmo…
Cheap@Coral.Calcium.Online” rel=”nofollow”>……
Buywithout prescription xiu…
Buy@Cheap.Accupril” rel=”nofollow”>.…
Buygeneric drugs nih…
Cheap@Accutane.10mg.20mg” rel=”nofollow”>.…
Buyit now ojb…
Order@Aciphex.Online” rel=”nofollow”>.…
Buynow it lmg…
Order@Discount.Aciphex” rel=”nofollow”>……
Buygeneric meds svb…
Cheap@Advair.Without.Prescription” rel=”nofollow”>……
Buyit now sge…
Buy@Cheap.Aggrenox” rel=”nofollow”>..…
Buygeneric meds dxy…
Buy@Cheap.Aldactone” rel=”nofollow”>..…
Buydrugs without prescription hak…
can@you.take.aciphex.and.nexium.at.the.same.time” rel=”nofollow”>..…
Buygeneric pills…
actonel@and.heart.irregularities” rel=”nofollow”>..…
Buyno prescription…
aldactone@kidney.problems” rel=”nofollow”>……
Buygeneric drugs…
actonel@and.dvt” rel=”nofollow”>.…
Buygeneric meds…
levaquin 500mg…
Buy_no prescription…
financial aid for alzheimer’s…
Buy_without prescription…
heart worm medication…
Buy_no prescription…
blood pressure medications…
Buy_now it…
hepatitis b shot…
Buy_it now…
drug trafficking in latin america…
Buy_drugs without prescription…
permanent removal of adult acne scars…
Buy_generic meds…
enhancement drugs…
Buy_no prescription…
drug test company…
Buy_without prescription…
social etiologies for patients with schizophrenia…
Buy_it now…
epson salt and lemon juice diet…
Buy_generic pills…
l91 energizer e2 lithium aa cells…
Buy_generic drugs…
how to buy glucose meter…
Buy_generic meds…
skin cancer foundation australia…
Buy_generic drugs…
clinical features of sickle cell disease…
Buy_generic drugs…
depression medcine xr…
Buy_drugs without prescription…
school age adhd self absorbed…
Buy_now it…
meal plan for hypertension…
Buy_generic drugs…
scabies in dogs help…
Buy_generic drugs…
herbals for pregnancy…
Buy_drugs without prescription…
diet secrets for models…
Buy_now it…
best@medicare.plan.d.for.nexium.40.mg” rel=”nofollow”>..…
Buygeneric meds…
infant@prevacid.dose” rel=”nofollow”>.…
Buygeneric drugs…