将Azure WebSite配置为始终解析为自定义域 [英] Configuring Azure WebSite to always resolve to Custom Domain

查看:229
本文介绍了将Azure WebSite配置为始终解析为自定义域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Azure网站上托管了一个Wordpress博客。博客本身效果很好,自定义域正确解析为Azure WebSite URL。但是,我希望配置网站,以便用户的浏览器始终显示自定义域,即使他们点击网站内的链接,而不是现在发生的事情,只要您点击网站中的任何链接,URL更改为 http://MyBlog.AzureWebSites.Net/ {Content Url} URL。我看到相关问题自定义域名在Azure网站上工作,但始终重定向到azurewebsites.net?,但在GoDaddy中禁用域转发并不能解决此URL问题。

I have a Wordpress Blog hosted on an Azure Website. The blog itself works great, and the Custom domain resolves correctly to the Azure WebSite URL. However, I'm hoping to configure the site such that the user's browser will always display the custom domain, even when they click a link within the site, rather than what happens now, which is as soon as you click any link within the site, the URL changes to the http://MyBlog.AzureWebSites.Net/{Content Url} URL. I see the related question Custom Domain Name on Azure site working, but always redirects to azurewebsites.net?, but disabling Domain Forwarding in GoDaddy doesn't solve this URL issue.

目标是让整个网站在用户浏览器中的www.MyBlog.com/下工作,而不是 http://MyBlog.AzureWebSites.Net/ {其他网址}一旦点击任何链接。根据文档配置自定义域名在Azure App Service 中,我已经使用GoDaddy配置了CNAME和averify记录,这些记录指向Azure网站的IP地址,并通过Azure门户添加自定义域。 URL www.MyBlog.com确实可以正确解析为 http://MyBlog.AzureWebSites.Net ,并保留作为www.MyBlog.com,直到用户点击网站内的任何链接(比如打开帖子),此时网址变为 http://MyBlog.AzureWebSites.Net/2015-12-01/MyFirstPost

The goal is to have the entire site working under www.MyBlog.com/ in the user's browser rather than http://MyBlog.AzureWebSites.Net/{rest of the url} as soon as they click any link . As per the documentation Configure a custom domain name in Azure App Service, I have configured the CNAME and averify records which point to the Azure Web Site's IP address with GoDaddy, as well as adding the "Custom Domain" via the Azure Portal. The URL www.MyBlog.com does resolve correctly to http://MyBlog.AzureWebSites.Net, and it stays as www.MyBlog.com until the user hits any link inside the site (say, opening a post), at which point, the URL becomes http://MyBlog.AzureWebSites.Net/2015-12-01/MyFirstPost

我看到一些文章关于如何通过更改web.config文件来实现此目的,例如 SEO提示:如何阻止* .azurewebsites.net域名,建议将其添加到Web.Config:

I see some articles on how to achieve this with changes to the web.config file, such as SEO Tip: How to block the *.azurewebsites.net domain, which suggests adding this to the Web.Config:

    <rule name="Disable Azure Domain" patternSyntax="Wildcard" stopProcessing="true">
      <match url="*" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTP_HOST}" pattern="*.azurewebsites.net" />
      </conditions>
      <action type="Redirect" url="http://www.example.com{REQUEST_URI}" redirectType="Permanent" />
    </rule>

但每当我尝试进行此更改时,两个网址都会停止解析。它们似乎进入一个无限循环,重定向到彼此。

but whenever I try to make this change, both URLs stops resolving. They appear to go into an infinite loop redirecting to each other.

我没有尝试从一个URL重定向到另一个URL。从本质上讲,我希望网络服务器始终取代 http://MyBlog.AzureWebSites.Net/ 的一部分。 URL与www.MyBlog.com/。值得注意的是,当我手动输入www.MyBlog.com/2015-12-01/MyFirstPost时,它会正确地为页面提供服务。

I'm not trying to redirect from one URL to another. Essentially, I want the webserver to always replace the http://MyBlog.AzureWebSites.Net/ part of the URL with www.MyBlog.com/ . It's worth noting that when I manually enter www.MyBlog.com/2015-12-01/MyFirstPost, it serves the page correctly.

推荐答案

这不是Azure问题,而是Wordpress问题。

This isn't an Azure issue, rather a Wordpress Issue.

当您设置Wordpress站点时,您选择站点域,然后在整个站点中使用它。

When you set up Wordpress site you choose the site domain and then this is used throughout the site.

在设置 - >常规屏幕上,有一个名为站点地址(URL)的字段。 站点地址(URL)设置是您希望用户在其浏览器中键入以访问WordPress博客的地址。

On the Settings-> General screen there is a field called "Site Address (URL)". The "Site Address (URL)" setting is the address you want people to type in their browser to reach your WordPress blog.

听起来你想要更新这个字段。

It sounds like you will want to update this field.

更多信息可以在这里找到: https://codex.wordpress.org/Changing_The_Site_URL

More information can be found here: https://codex.wordpress.org/Changing_The_Site_URL

有一些插件可以使这更容易如天鹅绒蓝调更新网址不仅更改站点URL,但更新嵌入在通常不会更新的页面中的任何内部链接或图像。

There are plugins that make this easier Such as Velvet Blues Update URLs not only changes the Site URL but updates any internal links or images embedded in pages that wouldn't ordinarily be updated.

这篇关于将Azure WebSite配置为始终解析为自定义域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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