简体   繁体   English

IIS重写更改文件名

[英]IIS rewrite change filename

I have some old URLs in a forum application points to http://mydomain.tld/showthread.php?p=xxxx where xxxx is the an integer id. 我在论坛应用程序中有一些旧URL指向http://mydomain.tld/showthread.php?p=xxxx ,其中xxxx是整数ID。

My new forum application uses viewtopic.php?p=xxxx and I want to handle this using IIS web.config rewrite rules. 我的新论坛应用程序使用viewtopic.php?p=xxxx ,我想使用IIS web.config重写规则来处理此问题。

I have tried to add the last rule as the following: 我试图添加最后一条规则如下:

<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>

However, it does not able to redirect to the viewtopic.php . 但是,它不能重定向到viewtopic.php Any suggestion? 有什么建议吗?

I have to enable httpRedirect in the IIS. 我必须在IIS中启用httpRedirect Then I used this redirect rule in the web.config at the root of my forum: 然后,在论坛根目录的web.config中使用了此重定向规则:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM