我想将我的一些其他域定向到我的主域,主域位于Windows Azure网站上.

(For the sake of those that find working with CNAME's and DNS a little "foggy" (like I did) I'm going to layout the details.)

我正确解析了域名www.myDomain.com.

我现在想指出www.myOtherDomain.com to www.myDomain.com

At my registrar I have created a CNAME to point
www.myOtherDomain.com to myInternalAzureSite.azurewebsite.net
and then successfully configured it in the in the Azure Website domain manager tool.

现在,当我在浏览器中输入www.myOtherDomain.com时,我在www.myDomain.com处得到了正确的网页,然而,浏览器中的地址仍然是www.myOtherDomain.com,而不是所需的www.myDomain.com.

我知道实现这一目标最理想的两种方法是:

  1. 远期myOtherDomain.com美元(在一些登记处的费用为美元)
  2. 执行301永久重定向

如果我都是正确的,我已经找到了很多HOW的建议来做301重定向,但是,我似乎想不出WHERE来实际放重定向?

推荐答案

Windows Azure网站运行IIS.您可以使用URL重写来创建将一个URL重写为另一个URL的规则.

说明:

  1. 在Windows Azure中创建网站.

  2. 在"zoom "区域中, Select 共享或标准的网站模式,然后保存更改.

  3. 在"配置"部分的"域名"组上,添加旧域名(或多个名称)和新域名并保存更改.

  4. 在旧域和新域的域注册商或DNSProvider 中,更改DNS记录以指向新的Windows Azure网站.使用"CNAME(Alias)"记录并将其指向Windows Azure上的网站域,如下所示:"mywebsite.azurewebsites.net."

  5. 将新网站的内容上载到Windows Azure.

  6. 在新网站的根目录中,创建一个名为Web.config的文件,其内容如下:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Redirect old-domain to new-domain" stopProcessing="true">
                        <match url=".*" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^www.old-domain.com$" />
                        </conditions>
                        <action type="Redirect" url="http://www.new-domain.com/{R:0}" redirectType="Permanent" />
                    </rule>              
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
    
  7. 验证对"http://www.old-domain.com/path?query"的任何请求都将收到"301永久移动"响应,其位置标题为"http://www.new-domain.com/path?query".

有关文件,请参阅第Using the URL Rewrite Module章.

有关示例,请参阅Redirect to new domain after rebranding with IIS Url Rewrite ModuleIIS URL Rewrite – Redirect multiple domain names to one.

Asp.net相关问答推荐

ASP.NET MVC项目中的产品采购并发性测试

无法在Microsoft Windows Server 2016(数据中心)上运行.NET可移植性分析器

如何在 ASP.NET RadioButtonList 中的项目之间添加空格

使用 Asp.Net MVC 和 KnockoutJS 处理日期

从数据库中检索数据的最快方法

如何将 viewbag 显示为 html?

ASP.NET Web 应用程序 (.NET Framework) 与 ASP.NET Core Web 应用程序 (.NET Framework) 之间的差异

用户NT AUTHORITY\NETWORK SERVICE登录失败

无法加载文件或程序集 'System.Web.Mvc,版本 = 3.0.0.0,Elmah.MVC 问题

ASP.NET Web 应用程序消息框

您对 Windows Workflow Foundation 有何体验?

如何使用 javascript 调用 ASP.NET c# 方法

如何配置 ASP.NET Core 1.0 以使用本地 IIS 而不是 IIS Express?

如何在 ASP.NET 下拉列表中添加选项组?

在 asp.net 中为动态 PDF 指定文件名

在asp.net mvc 3中实现FilterAttribute,IActionFilter和从ActionFilterAttribute继承有什么区别?

在 Asp.Net Core 中动态更改连接字符串

asp.net core 2.0 - 值不能为空.参数名称:连接字符串

IIS 是否执行非法字符替换?如果是这样,如何阻止它?

Page.IsPostBack 和 Page.IsCallBack 有什么区别?