将.aspx页面从http://(非安全)重定向到https://(安全)网站

问题描述:

大家好

假设我有两个站点是 https://test.com [ ^ ]和 http://test.com [

Hi All

suppose i have two sites are https://test.com[^] and http://test.com[^]

earlier my files were on http://test.com (non-secure) now i have migrated them on https://test.com (secure). So now there are no files on http://test.com (non-secure).

now i want to set a page(say default.aspx) on http://test.com (non-secure) that redirect me to https://test.com (secure site)?

how can i do this?

thanks,
krunal



您甚至可以使用 DNS条目从服务器重定向站点.这样,您不必在旧站点上保留默认页面.刚刚输入了一个条目来重定向新https位置上的页面.

如果要使用默认页面进行重定向,则可以使用 Response.Redirect 将页面更改为https.

希望它对您有用,
谢谢.
Hi,

You can even redirect your site using DNS entry from your server. That way you do not have to keep default page on your old site. just made one entry to redirect page on the new https location.

If you want to redirect using your default page then you can use Response.Redirect to change page to https.

Hope it works for you,
Thanks.


有几种方法可以做到这一点.检查此链接:

http://www.sslshopper.com/iis7-redirect-http-to-https.html [^ ]

我认为最简单的方法是设置自定义错误页面.尝试让我们知道!

干杯
There are several methods to do this. Check this link:

http://www.sslshopper.com/iis7-redirect-http-to-https.html[^]

I think that the simplest one is setting up a custom error page. Try and let us know!

Cheers


尝试在global.asax中跟随以下代码

//此代码仅适用于服务器
Try following code in global.asax

//This code work only on server
void Application_BeginRequest(object sender, EventArgs e) 
    {
        if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("http:"))
        {
            Response.Redirect(HttpContext.Current.Request.Url.ToString().ToLower().Replace("http:", "https:"));
        }
    }



谢谢



Thanks