码迷,mamicode.com
首页 > Web开发 > 详细

asp.net web page 301重定向

时间:2017-12-31 11:52:05      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:定向   stat   blog   log   moved   ons   ali   web   status   

@{

    var domain = "www." + helpers.Domain();

    var host = Request.Url.Host;

    var AbsolutePath = Request.Url.AbsolutePath;

    if (domain != host)

    {

        Response.Status = "301 Moved Permanently";

        Response.AddHeader("Location", "http://www.mastersws.com" + AbsolutePath);

    }

}

注释:为了兼容ie,带www的为200 ,非www为301。 同时也避免了自己跳转自己。

asp.net web page 301重定向

标签:定向   stat   blog   log   moved   ons   ali   web   status   

原文地址:https://www.cnblogs.com/master0919/p/8157150.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!