【问题标题】:Multiple domain pointing root folder need to point subfolders according to domain name in web.config多域指向根文件夹需要根据web.config中的域名指向子文件夹
【发布时间】:2015-10-15 13:00:51
【问题描述】:

我有三个域 domain1.comdomain2.comdomain3.com 都指向我的 Azure Web 应用程序 mysites.azurewebsite.net。在我的天蓝色网站的根文件夹中,三个可用的文件夹domain1domain2domain3 安装在这些文件夹上wordpress。目前我在web.config 中给出了以下设置,它指向相应的文件夹。

           <rule name="domain1" stopProcessing="true">
                <match url=".*"/>
                    <conditions logicalGrouping="MatchAny">
                        <add input="{HTTP_HOST}" pattern="^(www.)?domain1.com"/>
                    </conditions>
                <action type="Rewrite"  redirectType="Permanent" url="\domain1\{R:0}" />
            </rule>
             <rule name="domain2" stopProcessing="true">
                <match url=".*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^(www.)?domain2.com" />
                        <add input="{PATH_INFO}" pattern="^/domain2/" negate="true" />
                    </conditions>
                <action type="Rewrite" url="\domain2\{R:0}" />
            </rule>
             <rule name="domain3" stopProcessing="true">
                <match url=".*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^(www.)?domain3.com" />
                        <add input="{PATH_INFO}" pattern="^/domain3/" negate="true" />
                    </conditions>
                <action type="Rewrite" url="\domain3\{R:0}" />
            </rule>

我面临的问题是,当我点击任何子页面链接时,它会显示在错误下方

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

当我从我的 wordpress 管理员中禁用用户友好的 url(永久链接)时,它可以正常工作。但它在“关于我们”页面中显示为 mydomain.com/?page_id=1

在永久链接更改为用户友好的网址(如mydomain1.com/about-us)后,我怎样才能使其工作

由于每个子文件夹都有 wordpress 并且在 wordpress 中我启用了永久链接,因此无法正常工作。否则它工作正常

【问题讨论】:

    标签: wordpress azure web-config rewrite multiple-domains


    【解决方案1】:

    我没有完整的答案给你,但是每条规则上的 stopProcessing="true" 可能会让你有些悲伤,因为它会阻止规则被进一步处理,所以你的第二条和第三条规则将被忽略当您在第一条规则上设置此标志时。

    您的模式也设置为匹配所有三个规则上的“*\”,所以也许这样的规则可以工作:

    <rules>
       <rule name="Domain2">
          <match url="*.domain2.*" />
          <conditions>
             <add input="{UrlDecode:{QUERY_STRING}}" pattern="domain2" />
          </conditions>
          <action type="Rewrite" url="{HTTP_HOST}/domain2/" />
       </rule>
    </rules>
    

    【讨论】:

    • 我已经尝试过了,但不适合我。文件夹重定向已经按照我的规则为我工作。
    猜你喜欢
    • 2014-06-19
    • 1970-01-01
    • 1970-01-01
    • 2017-08-05
    • 2012-07-26
    • 2019-02-05
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多