【问题标题】:URL Rewrite RedirectionURL 重写重定向
【发布时间】:2021-03-17 18:54:04
【问题描述】:

我在 IIS 中配置了一个带有虚拟目录的网站。 (applicationHost.config文件如下)

<application path="/" applicationPool="TestMovieSearch">
    <virtualDirectory path="/moviesearch" physicalPath="C:\inetpub\wwwroot\fullmovielist" />
</application>

我正在使用 URLRewrite 将用户重定向到特定的 html 页面。我在此路径中放置了以下 webconfig 文件。

路径:C:\inetpub\wwwroot\fullmovielist

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Catch all for movie search redirection">
                    <match url="/" negate="true" />
                    <action type="Rewrite" url="/MovieSearch/action/movies.html" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

当我尝试 URL http:\localhost\MovieSearch 时,它正确地被重定向到 movies.html 页面。我只需要知道 web.config 文件如何与虚拟目录匹配 正确重定向到 movies.html 页面。

注意:我是 web.config 文件的新手。因此,我们将不胜感激。

【问题讨论】:

    标签: iis localhost web-config url-rewrite-module virtual-directory


    【解决方案1】:

    根据我的理解,你不需要重写规则,但你想知道这个重写规则是如何工作的,对吗?

    我猜你的 fullmovielist 文件夹中还有一个 action 文件夹,其中包含 movies.html。 (如果不是,就是你使用的MVC结构的应用。)

    如果你想知道url如何匹配规则并重写为新的,最好使用fail request tracing http://localhost/moviesearch,“/moviesearch”部分匹配“/”,改写为http://localhost/moviesearch/action/movies.html

    更多关于url重写的规则和方法可以从document了解。

    【讨论】:

      猜你喜欢
      • 2020-03-01
      • 2016-06-27
      • 2012-04-19
      • 2015-10-27
      • 2016-06-18
      • 2015-04-19
      • 2019-02-11
      • 1970-01-01
      相关资源
      最近更新 更多