Godaddy主机怎么设置301重定向

2025-07-14 18:39:25

1、PHP 301转向代码<?phpheader(“HTTP/1.1 301 Moved Permanently”);header(“Location: http://www.now.cn/newpage.html”);exit();?>2、ASP 301转向代码<%@ Language=VBScript %><%Response.Status=”301 Moved Permanently”Response.AddHeader “Location”, “http://www.now.cn”%>

2、Coldfusion 301转向代码下面代码保存为oldpagename.cfm<.cfheader statuscode=”301″ statustext=”Moved permanently”><.cfheader name=”Location” value=”http://www.now.cn/newpage.html”>4、ASP.NET 301转向代码private void Page_Load(object sender, System.EventArgs e){Response.Status = “301 Moved Permanently”;Response.AddHeader(“Location”,http://www.now.cn);}

3、规范WW掳姗浚瑙W(利用.htaccess实现301转向)如果是Linux服务器,并且ApacheMod-Rewrite开启的时候,你可以在网站跟目录中创建.htaccess文件,墩伛荨矧通过.htaccess可以把所有收录为now.cn的链接修改为www.now.cn,.htaccess必须放在网站所在的目录中(即网站首页在同一个文件夹内),请把下面的代码写入.htaccess文件RewriteEngine onrewritecond %{http_host} ^now.cn [nc]rewriterule ^(.*)$ http://www.now.cn/$1 [r=301,nc]6、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. 设置完成!

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢