【问题标题】:URL Rewrite iis serverURL重写iis服务器
【发布时间】:2021-06-16 16:38:18
【问题描述】:

我想将 url 重写为 index.html。下面的 web.config 完成这项工作,直到第一个路径。 例如:- test.com/test1 到 test.com/index.html 但它不适用于多个路径。例如:- test.com/test1/test2

我当前的 web.config

<configuration>
    <system.webServer>
        <rewrite>
        <rules>
            <rule name="redirect all requests" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
                </conditions>
                <action type="Rewrite" url="index.html" appendQueryString="true" />
            </rule>
        </rules>
    </rewrite>
    </system.webServer>
</configuration>

我不确定我在这里缺少什么。如果你们知道,请写下正确的 web.config。 谢谢。

【问题讨论】:

标签: regex redirect iis url-rewriting web-config


【解决方案1】:

你可以试试这个规则:

<rule name="test" stopProcessing="true">                    
  <match url="(.*)" />
    <conditions>
       <add input="{REQUEST_URI}" pattern="^/([^/]+)" />
    </conditions>
  <action type="Redirect" url="http://test.com/{C:1}/index.com" redirectType="Found" />
</rule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-07
    • 1970-01-01
    • 2011-08-08
    • 1970-01-01
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    • 2011-12-31
    相关资源
    最近更新 更多