【问题标题】:IIS rewrite change filenameIIS 重写更改文件名
【发布时间】:2016-06-23 18:48:15
【问题描述】:

我在论坛应用程序中有一些旧 URL 指向 http://mydomain.tld/showthread.php?p=xxxx,其中 xxxx 是整数 ID。

我的新论坛应用程序使用viewtopic.php?p=xxxx,我想使用 IIS web.config 重写规则来处理这个问题。

我已尝试将最后一条规则添加如下:

<rewrite>
            <rules>
                <rule name="Redirect www to non www" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Redirect" url="http://domain.tld/{R:1}" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^domain\.tld" negate="true" />
                    </conditions>
                </rule>

                <!-- this for change from showthread.php to viewtopic.php -->
                <rule name="Rewrite" stopProcessing="true">
                    <match url="(.*)showthread\.php" />
                    <action type="Rewrite" url="viewtopic\.php" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>

但是,它无法重定向到viewtopic.php。有什么建议吗?

【问题讨论】:

    标签: iis url-rewriting web-config


    【解决方案1】:

    我必须在 IIS 中 enable httpRedirect。然后我在论坛根目录的 web.config 中使用了这个重定向规则:

    <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
             <add wildcard="*showthread.php" destination="/viewtopic.php?$P" />
    </httpRedirect>
    

    【讨论】:

      猜你喜欢
      • 2021-12-22
      • 1970-01-01
      • 2014-02-24
      • 1970-01-01
      • 2015-06-08
      • 2012-08-15
      • 1970-01-01
      • 2011-03-01
      • 2018-11-19
      相关资源
      最近更新 更多