301转向代码
出自美国主机知识库
对
301转向代码
的源代码
跳转到:
导航
,
搜索
根据以下的原因,您无权限进行编辑这个页面操作:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
*PHP 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]
返回到
301转向代码
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
动作
搜索
导航
首页
美国主机侦探论坛
当前事件
最近更改
随机页面
帮助
工具/资源
查询Alexa排名
Gzip压缩检测
建站源代码下载
工具箱
链入页面
链出更改
特殊页面