Link to home
Start Free TrialLog in
Avatar of Ike McMahon
Ike McMahonFlag for United States of America

asked on

301 Redirects from ASPX to PHP files on IIS server

Hello Experts,

I have been tasked with converting an existing ASP.net (.aspx) site running on IIS to a PHP site running on IIS.  I can't use another Web server as there are some back-end items that are still in asp.net.  

My question is this:  What is the best way to do 301 Permanently Moved redirects?  I've read a bunch about using the .htaccess file in Apache, but not sure how to do this in IIS.  Also, the names of the pages are not going to be the same, and we have shrunk the site so many of the old aspx pages will go to the same php file.

Is there a way to do this in one file as in using the .htaccess?  The only other solution I can think of is to maintain all the aspx pages and do a response.redirect in each.  I was hoping to avoid doing that if possible.

Many thanks!

Ike1492
ASKER CERTIFIED SOLUTION
Avatar of pcsmitpra
pcsmitpra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DerekStone
DerekStone

You'll likely want to create (or find on the Web) an ASP.NET HttpModule that does redirection. The module get's configured in "web.config", and can use regular expressions or an XML file, for example, to do the mappings. Basically the module will "intercept" requests that it can rewrite (to a different URL). Luckily you're going from ASP.NET to PHP, which means the pages people are redirecting from (*.aspx) will still be fed through the ASP.NET pipeline, so this will work in IIS6 as well. IIS7 has an "integrated pipeline", meaning the modules will work regardless of the file extension (i.e. on non-ASP.NET pages).
Avatar of Ike McMahon

ASKER

pcsmitpra:  I understand that this can be done when one URL is being redirected to another - thanks!  In my case, the URL will remain the same, and individual aspx pages will need to be permanently moved to their php counterpart, and in a one to many fashion.

Ex.  www.xxxx.com/product1.aspx --> www.xxxx.com/product1.php
    & www.xxxx.com/product2.aspx --> www.xxxx.com/product1.php

I hope this helps clarify things.

Many thanks!

Ike1492
If this is IIS6 you should be able to use a wildcard redirect:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/41c238b2-1188-488f-bf2d-464383b1bb08.mspx?mfr=true

Nearly your exact senario is spelled out in the example for the $0 thru $9 variables.

A more powerful rules engine exists in IIS7 but there is no user interface (you'll need to modify the web.config).  Just above the samples section there is a similar example to what you want to do:
http://www.iis.net/ConfigReference/system.webServer/httpRedirect#006

not what I was looking for