Azure 网站 301 重定向 - 我把它放在哪里? [英] Azure Website 301 Redirect - Where Do I Put It?

查看:29
本文介绍了Azure 网站 301 重定向 - 我把它放在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的其他一些域定向到我在 Windows Azure 网站上托管的主域.

I want to direct some of my other domains to my primary domain which is hosted at a Windows Azure website.

(为了那些发现使用 CNAME 和 DNS 有点模糊"(就像我所做的)的人,我将布置细节.)

我已正确解析域 www.myDomain.com.

我现在想将 www.myOtherDomain.com 指向 www.myDomain.com

在我的注册商处,我创建了一个 CNAME 指向
www.myOtherDomain.com 到 myInternalAzureSite.azurewebsite.net
然后在Azure网站域管理工具中配置成功.

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.

Now, when I enter www.myOtherDomain.com into a browser I get the proper web page at www.myDomain.com, however, the address in the browser is still www.myOtherDomain.com not www.myDomain.com as desired.

我了解实现此目的的两种最理想的方法是:

I understand the two most desirable ways to accomplish this are either:

  1. 转发 myOtherDomain.com(某些注册商的费用为 $)
  2. 进行 301 永久重定向
  1. Forward myOtherDomain.com (which costs $ at some registrars)
  2. Do a 301 permanent redirect

如果我所有这些都是正确的,我已经找到了许多关于如何进行 301 重定向的建议,但是,我似乎无法弄清楚 WHERE 实际上把重定向?

If I have all that correct, I have found many suggestions of HOW to do the 301 redirect, however, I can't seem to figure out WHERE to actually put the redirect?

推荐答案

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

Windows Azure Websites run IIS. You can use URL rewriting to create rules to rewrite one URL to another.

说明:

  1. 在 Windows Azure 中创建网站.

  1. Create a website in Windows Azure.

在规模部分,选择共享或标准的网站模式并保存更改.

In the Scale section, select a web site mode of Shared or Standard and save changes.

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

In the Configure section, on the domain names group, add the old domain name (or names) and the new domain name and save changes.

在旧域和新域的域注册商或 DNS 提供商中,更改 DNS 记录以指向新的 Windows Azure 网站.使用CNAME(别名)"记录并将其指向 Windows Azure 上的网站域,例如:mywebsite.azurewebsites.net".

In your domain registrar or DNS provider for the old domain and the new domain, change the DNS records to point to the new Windows Azure Website. Use a "CNAME (Alias)" record and point it to the website's domain on Windows Azure, like this: "mywebsite.azurewebsites.net."

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

Upload your new website's contents to Windows Azure.

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

In the root of the new website, create a file named Web.config with a contents like this:

<?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>

  • 验证对http://www.old-domain.com 的任何请求/path?query" 将收到301 Moved Permanently"响应,其中包含http://www.new-domain.com/path?query".

  • Verify that any request to "http://www.old-domain.com/path?query" will receive a "301 Moved Permanently" response with a Location header for "http://www.new-domain.com/path?query".

    有关文档,请参阅使用URL 重写模块.

    示例参考使用 IIS Url Rewrite Module 重新命名后重定向到新域IIS URL Rewrite – 将多个域名重定向到一个.

    这篇关于Azure 网站 301 重定向 - 我把它放在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆