如何在一个域下托管两个应用程序

时间:2021-05-14 05:10:06

标签: asp.net-mvc wordpress hosting

目前我有一个涵盖我博客的 wordpress 网站。我有一个 asp.net mvc 应用程序,它是我的电子商务应用程序。

目前我希望将它们都放在一个域下,我想知道这可能吗?

访问时

TestWebSite.com 它将指向我的 wordpress

目前我将 asp.net mvc 应用程序设置为子域 shop.TestWebsite.com,但我希望将其设置为 TestWebsite.com/shop

我目前遇到的问题是配置 asp.net mvc 应用程序,以便当他们访问 www.TestWebsite.com/shop 时它会加载该应用程序。

任何提示将不胜感激

1 个答案:

答案 0 :(得分:0)

是的,是否可以使用 UrlRewrite 模块。在根 web.config 中添加自定义规则。此外,在 wordpress 文件夹中,您必须添加相应的 wordpress 重写 (.htaccess to web.config converter online)

    <system.webServer>
    <rewrite>
        <rules>
            <rule name="SUBDOMAIN" stopProcessing="false">
                <match url="(.*)"/>
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^SUBDOMAIN.domain.com$"/>
                    <add input="{PATH_INFO}" pattern="^/APPFOLDER/" negate="true"/>
                    <!-- This one! -->
                </conditions>
                <action type="Rewrite" url="APPFOLDER/{R:1}"/>
            </rule>
            <rule name="DOMAIN" stopProcessing="false">
                <match url="(.*)"/>
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^DOMAIN.com$"/>
                    <add input="{PATH_INFO}" pattern="^/WORDPRESSFOLDER/" negate="true"/>
                    <!-- This one! -->
                </conditions>
                <action type="Rewrite" url="WORDPRESSFOLDER/{R:1}"/>
            </rule>
        </rules>
    </rewrite>
</system.webServer>