IIS 10子域到文件夹

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IIS 10子域到文件夹相关的知识,希望对你有一定的参考价值。

请帮帮我。

我不会说英语,所以如果我在写作中犯错误,我会道歉(我使用谷歌翻译):(

使用以下功能创建我的网站:

Bindings > *.holos.mx, holos.mx 
Path > D:Hosteos

在这个目录D:Hosteosweb.config我有规则:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>

        <rewrite>

            <rules>
                <rule name="Imported Rule 0" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTP_HOST}" pattern="^(.*).holos.mx" ignoreCase="false" />
                        <!--<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />-->
                    </conditions>
                    <action type="Rewrite" url="{C:1}/{R:1}" appendQueryString="true" /><!-- .php -->
                </rule>

            </rules>
        </rewrite>

        <httpErrors errorMode="Custom">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/404.aspx" responseMode="ExecuteURL" />
        </httpErrors>

    </system.webServer>
</configuration>

创建此文件夹:D:Hosteoseta

在这个文件夹里面我有另一个web.config。 (d: Hosteos 测试的web.config)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>

                <clear />
                <rule name="Imported Rule 1">
                    <match url="^life(|/)$"  />
                    <action type="Rewrite" url="test.php" appendQueryString="false" />
                </rule>

            </rules>
        </rewrite>

        <httpErrors errorMode="Custom">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/404.html" responseMode="ExecuteURL" />
        </httpErrors>

    </system.webServer>
</configuration>

问题是当我通过URL子域名(http://beta.holos.mx/life)输入时显示错误404

当我输入URL基本域(http://holos.mx/beta/life)时,它会显示我的页面test.php的内容

我该如何解决?

答案

您需要在重写操作中更改URL。

你的规则应该是这样的:

<rule name="Imported Rule 0" stopProcessing="true">
    <match url="^(.*)$" />
    <conditions logicalGrouping="MatchAll">
        <add input="{HTTP_HOST}" pattern="^(.*).domain.com" ignoreCase="false" />
    </conditions>
    <action type="Rewrite" url="http://holos.mx/{C:1}/{R:1}" appendQueryString="true" /><!-- .php -->
</rule>

以上是关于IIS 10子域到文件夹的主要内容,如果未能解决你的问题,请参考以下文章

IIS 站点部署多级域名

iis 中具有多个子域的 asp.net mvc 站点

发布到 IIS 10 的 api 不反映最新代码

使用 IIS express 在域和子域之间共享 cookie

IIS7中的通配符子域。是否有可能使它们像在Apache中一样?

从 MVC / IIS Web 应用程序向子域提供服务