I have an asp.net mvc3 website. It replaced an older php website. Many people have parts of the site bookmarked in reference to the .php locations and I would like to add those back into the asp.net site as simple forwards to the new location. So mysite/product.php would redirect to mysite/usermap/product.cshtml for example. When I insert the product.php into the directory and use an anchor href to it, I am prompted to open it with a certain program or save it. Any ideas?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
If you are using IIS7 the Url rewrite module is great. Here is the page: http://www.iis.net/download/urlrewrite
Update the handler mappings manually. However I am pretty sure when you install PHP for IIS (http://php.iis.net/) it will do it for you.
You could make a small redirection controller, and add a route to match something like
mysite/{id}.php
.Then in that controller
edit
In your global.asax.cs file
Then you would define an
OldPathRedirectionController
(Controllers/OldPathRedirectionController.cs
most likely)I cleaned that up a little from the original recommendation. That hopefully should be enough to get you started! Obvious changes are to not hardcode the map of php filenames to mvc controllers, and perhaps altering the route to allow extra params if you require that.
Install PHP into IIS using this site. http://php.iis.net/