问题
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?
回答1:
You should be able to redirect with javascript if PHP doesn't work:
<script type="text/javascript">
window.location = "more.asp";
</script>
回答2:
Can't you use the web.config, the MS equavalent of .htaccess? http://msdn.microsoft.com/en-us/library/ms972974.aspx
回答3:
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!
回答4:
In that case you should install php on your IIS server => http://php.iis.net/ As far as I know you can't tell IIS to render php files as something else.
来源:https://stackoverflow.com/questions/11462996/having-trouble-redirecting-old-php-url-to-the-new-asp-page