简体   繁体   English

适用于多个域和多语言路径的IIS 7.5 WinServer 2008 R2 URL重写模块

[英]IIS 7.5 WinServer 2008 R2 URL Rewrite Module for multiple domains and multilingual paths

I am attempting to utilize (per the title) the IIS URL Rewrite Module to redirect some old domains to new domains. 我试图利用(按标题)IIS URL重写模块将一些旧域重定向到新域。 I've looked through a lot of MS Tech articles and various blogs and, for our situation, I think I have an idea of the solution required, however, my redirects aren't firing and I am only getting a 404 error instead of redirects to pages. 我浏览了许多MS Tech文章和各种博客,就我们的情况而言,我认为我对所需的解决方案有所了解,但是,我的重定向未触发,并且仅收到404错误而不是重定向到页面。


Details: We currently have a multilingual site set up like domain. 详细信息:我们目前已经建立了一个多语言站点,例如domain。 com / English/Path/To/Page and domain. com / 英文/路径/收件人/页面和域。 de / English/Path/To/Page , domain. de / English / Path / To / Page ,域。 fr / English/Path/To/Page . fr / 英文/路径/到/页面 Our CMS - Kentico - is setup such that these translate per the top level domain name. 我们的CMS-Kentico-已设置为可根据顶级域名进行翻译。 We are now migrating to a new site and we want domain. 我们现在正在迁移到新站点,并且需要域名。 com / English/Path/To/Page and domain. com / 英文/路径/收件人/页面和域。 de / German/Translated/Path/To/Page and domain. de / 德语/翻译/路径/到/页面和域。 fr / French/Translated/Path/To/Page . fr / 法语/翻译/路径/到/页面 I believe the following is the correct way to setup the 'rewriteMaps': 我相信以下是设置“ rewriteMaps”的正确方法:

<rewrite>
    <rewriteMaps>
      <rewriteMap name="USRedirects" defaultValue="">
          <add key="/OLD/PATH/" value="/NEW/PATH/ENGLISH" />
          <add key="/OLD/PATH/" value="/NEW/PATH/ENGLISH" />
          <add key="/OLD/PATH/" value="/NEW/PATH/ENGLISH" />
       </rewriteMap>
    </rewriteMaps>
</rewrite>
<rewrite>
    <rewriteMaps>
      <rewriteMap name="DERedirects" defaultValue="">
          <add key="/OLD/PATH/" value="/NEW/PATH/GERMAN" />
          <add key="/OLD/PATH/" value="/NEW/PATH/GERMAN" />
          <add key="/OLD/PATH/" value="/NEW/PATH/GERMAN" />
       </rewriteMap>
    </rewriteMaps>
</rewrite>

Note: the 'old paths' are all the same and all in English. 注意:“旧路径”都是相同的,都是英文。 only the domains (.de, .com, .fr) denote the difference. 仅域(.de,.com,.fr)表示差异。 Going forward, the new site has translated URLs in each language. 展望未来,新网站已翻译了每种语言的URL。 I then have the following setup as my rules section: 然后,将以下设置作为我的规则部分:

<rules>
    <rule name="US Redirects" patternSyntax="ECMAScript" stopProcessing="true">
    <match url=".*" /> <!-- rule back reference is captured here  -->
    <conditions>
        <add input="{USRedirects:{HTTP_HOST}}" pattern="^www.domain.com$" /> <!-- condition back-reference is captured here -->
    </conditions>
    <action type="Redirect" url="http://www.domain.com/{R:1}" redirectType="Permanent" /> <!-- rewrite actions uses back-references to condition and to rule when rewriting the URL -->
     </rule>
   </rules>

<rules>
    <rule name="DERedirects" patternSyntax="ECMAScript" stopProcessing="true">
    <match url=".*" /> <!-- rule back reference is captured here  -->
    <conditions>
        <add input="{USRedirects:{HTTP_HOST}}" pattern="^www.domain.de$" /> <!-- condition back-reference is captured here -->
    </conditions>
    <action type="Redirect" url="http://www.domain.de/{R:1}" redirectType="Permanent" /> <!-- rewrite actions uses back-references to condition and to rule when rewriting the URL -->
     </rule>
   </rules>

In the end, I want a set of rules named for each language/domain (DE=domain.de, US=domain.com, FR=domain.fr, etc. and each one of those will correspond to the appropriate rewriteMaps (named DERedirects, USRedirects, FRRedirects, etc.) using the reference syntax in the input value {:{HTTP_HOST}}. 最后,我想要为每种语言/域(DE = domain.de,US = domain.com,FR = domain.fr等)命名的一组规则,其中每个规则都将对应于相应的rewriteMaps(命名为DERedirects,USRedirects,FRRedirects等),使用输入值{:{HTTP_HOST}}中的引用语法。

After all is said and done (and quite a few missteps with syntax which ended in 500 errors of course) this doesn't crash or 500 on me but the only thing it does is throw a 404 and say the page that I want redirected does not exist. 归根结底,这确实没有崩溃或对我造成了500错误,但唯一要做的就是抛出404并说我要重定向的页面了不存在。

Any help would be GREATLY appreciated. 任何帮助将不胜感激。 And, if there's any further information I am leaving out that would be important, please let me know and I will do what I can to provide more detail. 而且,如果我有其他重要的信息要漏掉,请告诉我,我会尽力提供更多详细信息。

Here are a couple of the references I've been using: 这是我一直在使用的一些参考:

http://ruslany.net/2010/05/storing-url-rewrite-mappings-in-a-separate-file/ http://ruslany.net/2010/05/storing-url-rewrite-mappings-in-a-separate-file/

https://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference https://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference

http://weblogs.asp.net/owscott/iis-url-rewrite-redirect-multiple-domain-names-to-one http://weblogs.asp.net/owscott/iis-url-rewrite-redirect-multiple-domain-names-to-one

Thanks! 谢谢!

small UPDATE: The above sections are only partials of the overall configuration. 小更新:上面的部分只是整体配置的一部分。 I need many more than just DE and COM setups. 我需要的不只是DE和COM设置。

Also, the Ruslany article I TRIED to implement but received too many 500 errors in getting it setup. 另外,我尝试实现的Ruslany文章,但是在设置它时收到了太多500错误。 Something with syntax or setup wasn't working correctly so I am putting all the maps and rules directly into the web.config file (while keeping it under 250kb per the rquirement). 语法或安装程序无法正常工作,因此我将所有映射和规则直接放入web.config文件中(同时根据要求将其保持在250kb以下)。

Found my answer! 找到了我的答案! Just had to figure out/realize that "{:{HTTP_POST}}" as the input was not possible to do then I could search correctly. 只是必须弄清楚/意识到“ {:{HTTP_POST}}”,因为无法进行输入,所以我可以正确搜索。 Found this post: 找到了这篇文章:

http://forums.iis.net/t/1177509.aspx http://forums.iis.net/t/1177509.aspx

and, in case that disappears from the interwebs, here is the copy/pasted version: 并且,如果从互连网上消失,则为复制/粘贴版本:


Hi, 你好

The input of request url in rewrite module doesn't contain host name. 重写模块中的请求URL输入不包含主机名。 So you need to use {HTTP_HOST} to verify it. 因此,您需要使用{HTTP_HOST}进行验证。 You can update your rules as following to make them work: 您可以按照以下说明更新规则以使其起作用:

<rewrite>
  <rewriteMaps>
    <rewriteMap name="Site1Redirects">
      <add key="/mypage" value="/EN/mypage.aspx" />
    </rewriteMap>
    <rewriteMap name="Site2Redirects">
      <add key="/mypage" value="/CY/mypage2.aspx" />
    </rewriteMap>
  </rewriteMaps>
  <globalRules>
    <rule name="Redirect rule1 for Site 1" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^site1.mysite.com$" />
        <add input="{Site1Redirects:{REQUEST_URI}}" pattern="(.+)" />
      </conditions>
      <action type="Redirect" url="{C:0}" appendQueryString="false" />
    </rule>
    <rule name="Redirect rule1 for Site 2" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^site2.mysite.com$" />
        <add input="{Site2Redirects:{REQUEST_URI}}" pattern="(.+)" />
      </conditions>
      <action type="Redirect" url="{C:0}" appendQueryString="false" />
    </rule>
  </globalRules>
</rewrite>

Thanks. 谢谢。


That is all ... 就这些 ...

UPDATE: just because I found this as further, valuable information: 更新:仅仅因为我发现这是更有价值的信息:

https://moz.com/blog/what-every-seo-should-know-about-iis#chaining https://moz.com/blog/what-every-seo-should-know-about-iis#chaining

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用IIS 7.5,Windows Server 2008 R2和.net Framework 4.5托管网站 - Host Website using IIS 7.5 ,Windows server 2008 R2 and .net framework 4.5 DoD CAC身份验证 - 使用.NET C#,Windows Server 2008 R2,IIS 7.5的客户端证书问题 - DoD CAC Authentication - Client Certificate Issue with .NET C#, Windows Server 2008 R2, IIS 7.5 在Windows Server 2008 R2 SP1的IIS 7.5上注册.NET 4.5的安全方法 - Secure way for registering .NET 4.5 on IIS 7.5 on Windows Server 2008 R2 SP1 无法在Windows Server 2008 R2上的IIS7.5中使用net.pipe绑定 - Can't get net.pipe binding working in IIS7.5 on Windows Server 2008 R2 IIS URL从多个域重写为非www - IIS URL rewrite from multiple domains to non-www 过去可以使用的ASP.NET(VB)应用程序现在在2008 R2 IIS 7.5上提供“重载解析失败” - ASP.NET (VB) app used to work, now gives “Overload resolution failed” on 2008 R2 IIS 7.5 在iis上启用URL重写模块 - enable URL rewrite module on iis 如何在web.config文件(iis 7.5)中重写URL? - How do rewrite the url in web.config file(iis 7.5)? 在Windows Server 2008 R2上将.Net Framework与IIS集成 - integrating .Net Framework with IIS on windows server 2008 r2 Windows 2008 R2 上的 TLS 1.2、.NET Framework 4.0 和 IIS 7.0 - TLS 1.2, .NET Framework 4.0, and IIS 7.0 on Windows 2008 R2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM