将旧的PHP URL重定向到新的ASP页面时遇到问题


Having trouble redirecting old PHP URL to the new ASP page

我不是ASP程序员。人们仍然使用这个系统建立在PHP上时的链接。

旧网址:www.domain.com/shop/more.php

新网址:www.domain.com/shop/more.asp

它现在运行在没有安装PHP的Windows服务器上。如果我创建了旧的PHP文件,那么用户在访问时会被要求下载.PHP文件。

我的研究让我了解到,我可以通过编辑web.config文件(在页面的根目录或文件夹中)来解决这个问题,但我所做的所有更改要么导致错误,要么什么都没做。

我也考虑过将默认的404页面重定向到正确的页面,但我的尝试也得到了同样的结果。

有人有什么见解吗?有没有办法找到网站运行的ASP版本?

如果PHP不工作,您应该能够使用javascript重定向:

<script type="text/javascript">
   window.location = "more.asp";
</script>

你不能使用web.config吗?http://msdn.microsoft.com/en-us/library/ms972974.aspx

为此使用web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true" />
        <rewrite>
            <rules>
                <rule name="CanonicalHostNameRule" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^www'.example'.com/something.php" negate="true" />
                    </conditions>
                    <action type="Redirect" url="http://www.example.com/something.aspx" />
                </rule>
            </rules>
        </rewrite>
  </system.webServer>
</configuration>

我一生中从未使用过ASP,所以这可能不起作用,但希望它能引导你走上正轨。

祝你好运!

NINJA编辑:

刚刚发现这个可能有帮助吗?

<add name="en_index"
               redirect="Domain"
               ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite"
               virtualUrl="http://mysitename/en/(.*).php"
               redirectMode="Permanent"
               destinationUrl="http://mysitename/en/$1.aspx" />

可能有帮助吗?

我在这里转述了这一点(向下滚动):http://our.umbraco.org/forum/core/general/14366-redirect-html-to-aspx

再次祝你好运!

在这种情况下,您应该在IIS服务器上安装php=>http://php.iis.net/据我所知,您不能告诉IIS将php文件呈现为其他文件。