301转向代码转向

出自美国主机知识库

(修订版本间的差异)
跳转到: 导航, 搜索
(以内容“*PHP 301转向代码 <?php header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.idcspy.com/newpage.html"); exit(); ?> *ASP 301转向代码 <%@ Lang...”创建新页面)
(以“#dedirect 301转向代码”替换内容)
第1行: 第1行:
-
*PHP 301转向代码
+
#dedirect [[301转向代码]]
-
 
+
-
<?php
+
-
header("HTTP/1.1 301 Moved Permanently");
+
-
header("Location: http://www.idcspy.org/newpage.html");
+
-
exit();
+
-
?>
+
-
 
+
-
*ASP 301转向代码
+
-
 
+
-
<%@ Language=VBScript %>
+
-
<%
+
-
Response.Status="301 Moved Permanently"
+
-
Response.AddHeader "Location", "http://www.idcspy.org"
+
-
%>
+
-
 
+
-
*Coldfusion 301转向代码
+
-
下面代码保存为oldpagename.cfm
+
-
<.cfheader statuscode="301" statustext="Moved permanently">
+
-
<.cfheader name="Location" value="http://www.idcspy.org/newpage.html">
+
-
 
+
-
*ASP.NET 301转向代码
+
-
 
+
-
private void Page_Load(object sender, System.EventArgs e)
+
-
{
+
-
Response.Status = "301 Moved Permanently";
+
-
Response.AddHeader("Location","http://www.idcspy.org");
+
-
}
+
-
 
+
-
*规范WWW(利用.htaccess实现301转向)
+
-
如果是Linux服务器,并且ApacheMod-Rewrite开启的时候,你可以在网站跟目录中创建.htaccess文件,通过.htaccess可以把所有收录为idcspy.org的链接修改为www.idcspy.org,
+
-
.htaccess必须放在网站所在的目录中(即网站首页在同一个文件夹内),请把下面的代码写入.htaccess文件
+
-
RewriteEngine on
+
-
rewritecond %{http_host} ^idcspy.org [nc]
+
-
rewriterule ^(.*)$ http://www.idcspy.org/$1 [r=301,nc]
+
-
 
+
-
*IIS中实现301重定向
+
-
 
+
-
如果你的是Windows服务器,可以通过设置IIS实现301重定向
+
-
点击the Internet Services Manager,然后选择需要重定向的文件或文件夹
+
-
鼠标右键,选择 a redirection to a URL.
+
-
指定要重定向的文件名
+
-
选择 The exact URL entered above.
+
-
选择 A permanent redirection for this resource.
+
-
点击 Apply. 设置完成!
+
-
 
+
-
*301转向 domain.com 到 www.domain.com代码
+
-
RewriteEngine On
+
-
RewriteBase /
+
-
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
+
-
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
+
-
 
+
-
*301转向 www.domain.com 到 domain.com  .htaccess代码:
+
-
RewriteEngine On
+
-
RewriteBase /
+
-
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
+
-
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
+

在2011年12月14日 (三) 06:37所做的修订版本

  1. dedirect 301转向代码
个人工具
名字空间
变换
动作
导航
工具/资源
工具箱