I was in the process of cleaning up my web hosting accounts when I came across one plan which had 2 sites on it. One of them was a static website (pure html) and the other one was written in classic asp. So I decided to move both sites to another hosting plan because it was just a waste of money as the sites did not have much traffic and there was no justification why the hosting was needed.
Since windows hosting plans are more expensive, I wanted to move the sites to a linux server and I knew I wouldn’t have any problems with the html website but I wondered how much trouble it would be to move the classic asp website. The code for the dynamic website was not using a lot of asp code as in only the files ended with an .asp extension but a php parser could very well serve the webpage. So after much googling, I found that adding a line to the .htaccess file would map any file extension to the php and that would do the trick for me.
Mapping asp to php parser
The line below will tell the php parser to treat files ending with .asp extension as if they were a php file.
AddType application/x-httpd-php .asp
How the above line did not work for me and I had a lot of problems trying to map the classic asp code before I found the solution. It has something to do with the version of php you’re using. Mine was 5.12.53 I think. I added the following lines in my .htaccess file and it worked:
AddType application/x-httpd-php4 .asp
AddType application/x-httpd-php5 .asp
Both lines are required. There’s something else that you need to do if you can’t get it to work. You can replace AddType with AddHandler (that depends if you’re running Apache as a module or CGI script). And sometimes you might need to remove the application word and have only this:
AddHandler x-httpd-php5 .asp
If you wanted to map another extension, you would do this:
AddType application/x-httpd-php5 .html .htm .me .newextension
Files ending with .html, .htm, .me and .newextension will then be run through the php parser and it would allow you to serve dynamic content through .html files or hide (disguise) the programming language you’re using on your website or make it easy to move from one coding language to another because if you don’t use a file extension reserved for a particular programming language, then you can easily switch to another programming language or server.
While mapping another extension, I also did two other things:
Define a default document (so that index.asp would be recognised as a default webpage for the folder/directory) –
DirectoryIndex index.html index.htm index.php index.asp
Disable directory browsing (so that folders/directories without a default webpage are not listed) –
Options -Indexes
Well so far so good, now just waiting for DNS propagation to complete before I can cancel the hosting plan.