簡體   English   中英

URL重寫到子域

[英]URL Rewrite to subdomain

對於 URL 重寫,我需要 support.mydomain.com 指向 mydomain.com/support。 我所擁有的是重寫 support.mydomain.com/support。

我嘗試了 2 種不同的變體,但沒有運氣。 任何幫助是極大的贊賞。

版本 1

<rewrite>
    <rules>
        <rule name="rewrite support" enabled="true">
            <match url="(.*)" />
            <conditions logicalGrouping="MatchAny">
        <add input="{HTTP_HOST}" pattern="^support.mydomain.com$" />
        </conditions>
        <action type="Rewrite" url="\support\{R:0}" />
        </rule>
    </rules>
</rewrite>

版本 2

<rule name="Support Rule" stopProcessing="false">
    <match url="(.*)" />
     <conditions>
         <add input="{HTTP_HOST}" pattern="^(?!www)(\w+)\.mydomain\.com$" />
     </conditions>
     <action type="Rewrite" url="{C:1}/{R:1}" />
</rule>

我能夠找到 Scott Forsyth 的這篇文章,它對我有用。

正如他在文章中所說:“這會將鏈接 http://anything_except_www.domain.com 重定向到 http://domain.com/anything_except_www。”

<rewrite>
    <rules>
        <rule name="CName to URL" stopProcessing="true">
            <match url=".*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^(?!www)(.*)\.domain\.com$" />
            </conditions>
            <action type="Redirect" url="http://domain.com/{C:1}/" />
        </rule> 
    </rules>
</rewrite>

希望這可以幫助某人!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM