简体   繁体   中英

Having trouble redirecting old PHP URL to the new ASP page

I am not an ASP programmer. People still use a link from a time when this system was built on PHP.

Old url : www.domain.com/shop/more.php

New url : www.domain.com/shop/more.asp

It now runs on a Windows server that doesn't have PHP installed. If I create the old PHP file then the user is asked to download the .php file when visiting.

My research has taken me to learn that I can fix this by editing the web.config file (in either the root or the folder of the page) but all my changes have either caused errors or done nothing.

I have also considered just making the default 404 page redirect to the correct page in question but my attempts have found the same result.

Does anyone have any insight? Is there a way to find out what version of ASP the site is running?

You should be able to redirect with javascript if PHP doesn't work:

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

Can't you use the web.config, the MS equavalent of .htaccess? http://msdn.microsoft.com/en-us/library/ms972974.aspx

Use web.config for this:

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

Never used ASP in my life so this might not work but hopefully it'll lead you on the right track.

Good luck!

NINJA EDIT:

Just found this which might help?

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

Might help?

I paraphrased this from here (scroll down): http://our.umbraco.org/forum/core/general/14366-redirect-html-to-aspx

Again, good luck!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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