Google已經使用HTTPS和HTTP將我們的一些頁面編入索引。我想將不應該是HTTPS的頁面重定向回HTTP(301)。將HTTPS中的某些頁面重定向到HTTP
這是一個EPiServer 7站點,但本質上是MVC。
我有我的控制器下面..
if (currentPage.RequireSsl != null && currentPage.RequireSsl.Value && !HttpContext.Request.IsSecureConnection)
{
if (HttpContext.Request.Url != null)
{
return this.RedirectPermanent(HttpContext.Request.Url.ToString().Replace("http:", "https:"));
}
}
else if (HttpContext.Request.IsSecureConnection && (currentPage.RequireSsl == null || currentPage.RequireSsl.Value == false))
{
if (HttpContext.Request.Url != null)
{
return this.RedirectPermanent(HttpContext.Request.Url.ToString().Replace("https:", "http:"));
}
}
現在,我想要做什麼,如果「安全」頁面請求非HTTPS,它301S爲https(在拉琴查看時)。
**GET http://domainxx.com/section/securepage/
301 Moved Permanently to https://domainxx.com/section/securepage/**
不過,如果我要求對HTTPS非安全頁面,將其重定向,但我得到一個200個狀態碼,而不是301提琴手甚至沒有列出直接:
**GET http://domainxx/section/notsecurepage/
200 OK (text/html)**
OK,其實這是OK ..提琴手ISN沒有選擇HTTPS請求,但http://www.howto301redirect.com/301-redirect-checker/是,並且工作正常。 – mp3duck