Ric*_*ard 32 asp.net iis redirect web-config azure
我想将我的其他一些域名引导到我的主域名,该域名是在Windows Azure网站上托管的.
(为了那些发现使用CNAME和DNS的人有点"模糊"(就像我做的那样)我将布置细节.)
我www.myDomain.com正确地解析了域名.
我现在想指出 www.myOtherDomain.com to www.myDomain.com
在我的注册商处,我创建了一个CNAME指向
www.myOtherDomain.com to myInternalAzureSite.azurewebsite.net
,然后在Azure网站域管理器工具中成功配置它.
现在,当我进入www.myOtherDomain.com到浏览器中获得正确的网页的www.myDomain.com,但是,在浏览器的地址仍然www.myOtherDomain.com没有www.myDomain.com达到目标.
我理解实现这一目标的两种最理想的方法是:
myOtherDomain.com(某些注册商的费用为$)如果我有所有正确的,我已经找到了很多建议如何做301重定向,但是,我似乎无法找出WHERE实际上把重定向?
Fer*_*eia 59
Windows Azure网站运行IIS.您可以使用URL重写来创建规则以将一个URL重写为另一个URL.
说明:
在Windows Azure中创建一个网站.
在"缩放"部分中,选择"共享"或"标准"的网站模式并保存更改.
在"配置"部分的"域名"组中,添加旧域名(或多个名称)和新域名并保存更改.
在旧域和新域的域名注册商或DNS提供商中,将DNS记录更改为指向新的Windows Azure网站.使用"CNAME(别名)"记录并将其指向Windows Azure上的网站域,如下所示:"mywebsite.azurewebsites.net".
将新网站的内容上传到Windows Azure.
在新网站的根目录中,创建一个以这样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>
Run Code Online (Sandbox Code Playgroud)验证是否有任何请求" http://www.old-domain.com/path?query "将接收与"Location头一个"301永久移动"响应http://www.new-domain.com/path ?查询 ".
有关文档,请参阅使用URL重写模块.
有关示例,请参阅使用IIS Url重写模块和IIS URL重写后重定向到新域- 将多个域名重定向到一个.
您还可以通过将此代码放在节点web.config下的文件中来进行重定向configuration:
<configuration>
<location path="oldpage1.php">
<system.webServer>
<httpRedirect enabled="true" destination="http://domain.com/newpage1" httpResponseStatus="Permanent" />
</system.webServer>
</location>
<location path="oldpage2.php">
<system.webServer>
<httpRedirect enabled="true" destination="http://domain.com/newpage2" httpResponseStatus="Permanent" />
</system.webServer>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
无需上传web.config文件,因为您可以通过Azure界面访问其中一个文件。
打开您的App Service的设置窗格,然后在左侧菜单底部的“开发工具”部分中单击“ App Service编辑器(预览)”。
单击执行以在新选项卡中打开编辑器。您将在左侧看到web.config文件。单击它以在主窗格中进行编辑。
一句话警告-该编辑器在您键入时自动保存!我敢肯定我们都会这样做,但我建议您在编辑器中准备代码并将其粘贴。
我能够添加一个部分,而不必手动重新启动App Service。
| 归档时间: |
|
| 查看次数: |
25408 次 |
| 最近记录: |