Executing .asp files as PHP

software development


Hi, I’m going to move an existing site on another server to Dreamhost. Currently, this site is running ASP, but I’m migrating its contents to Wordpress.

To help the current visitors and web robots find the new pages, I need some way to redirect all visits to “index.asp” to the new pages. The whole site runs on “index.asp”, so I would need to redirect every visit on “index.asp” to “/”.

I’ve made a little experiment. I uploaded these .asp files to one of my hosted sites on Dreamhost:

http://railes.net/test1.asp (using refresh meta tag)
http://railes.net/test2.asp (trying to execute ASP code)
http://railes.net/test3.asp (trying to execute PHP code)

None of them worked as expected on Firefox. The first one worked fine on Internet Explorer, though. But I would like some way to make it work in all browsers, as well on web robots like googlebot.

Is there any way to execute PHP on .asp files? That way I could get the URL parameters (like http://mysite.com/index.asp?idpage=321) and redirect the user to the new location of the corresponding idpage.

Thanks for the help!

Burning airlines give you so much more


To parse PHP contained within .asp files, add the following line to .htaccess in the root directory of your site:

AddHandler application/x-httpd-php .asp Note that ASP is Windows-only, which is why your .asp files aren’t being handled as anything but plain text. This will allow your first and third tests to work, but the second never will because ASP/VBScript is not supported.

The reason the first test works in IE is due to a bug: IE will try to guess what do do based on the contents of a file rather than the Content-Type header sent by the server. I thought this was fixed with recent IE patches, but I could be wrong.

If you want useful replies, ask smart questions.


Not fixed yet. It was held off cause it would break a lot of sites. So they decided to slate it for IE7.


Not fixed yet. It was held off cause it would break a lot of sites. So they decided to slate it for IE7. [/quote]
That’s what people get for building their site on IE quirks instead of trying to make them as standards compliant as they can. I say let 'em break :P. It shouldn’t take someone with sense that much time to fix a site that they see is broken.

The Insane Cabbit
Blog: http://www.sounanda.com
Store: http://www.marciesgifts.com
PM for CMS or forum install.
[color=#CC0000]$97 Off[/color] with promo code pixiedust