March 26, 2010

How to make Apache handle. asp and .aspx links in FreeBSD or Linux?

Filed under: FreeBSD — J. Abram barneck @ 2:00 am
Tags: , , ,

Ok, so what do you do when a site that was based on asp.net is converted to a Linux box and your product shipped with links to sites such as http://our.home.page/index.asp and many other .asp or aspx sites?

Should you use mono?
Maybe / Not yet.

Well, some might mention the mono project to you. Maybe taking the time to get mono working is worth it to you. However, I still haven’t gotten past the fact that it might be infringing on Microsoft copyrights and/or patents, so I have steered clear of it so far. That doesn’t mean that you shouldn’t investigate it further. This is a great project, and if it can manage to evade the copyright and patent infringements it will be, in my opinion, one of the most important open source projects in the future.

Also, since it doesn’t have anywhere near the functions that .NET 3.5 (or .NET 4.0 which is shortly to be released) you may find yourself rewriting almost as much code as if you switched to a language such as php.

Should you migrate your code to php or ruby or another open source language?
Yes, probably

This is what I would have to recommend at this point because it might be easy to re-write your code in php or ruby or any other open source language, especially if you are doing nothing more than echoing html code after performing simple calculations.

I haven’t tested it yet, but you may get a lot of the asp code automatically converted using this tool: asp2php

What about the fact that unchangeable links to my pages end with .asp or .aspx entensions?
It doesn’t matter what the file extension is, you can have that file extension handled by any scripting language. For example, to configure Apache to have php handle .asp or aspx file, you can follow the steps below.

If you have an index.asp file that should automatically be served by default, it is probably not in the list of files to serve by default, which is probably just index.htm and index.php. You can either rename index.asp to index.php or modify the httpd.conf to include the index.asp file. These steps assume you are changing the httpd.conf.

  1. Change to the apache configuration directory: /usr/local/etc/apache22/
  2. Edit the httpd.conf with ee.
    ee httpd.conf
  3. Search for “DirectoryIndex” to find the section where the directory index is configured.
  4. Add index.asp as the first item as shown:
    DirectoryIndex index.asp index.php index.html
  5. Change to the “Includes” directory which by default is here: /usr/local/etc/apache22/Includes
  6. Create a file that is named ending in .conf (For example, to show what the file does in the name, I used asp-as-php5.conf):
    # Handle .asp and .aspx with php
    AddType application/x-httpd-php .asp
    AddType application/x-httpd-php .aspx
  7. Restart apache. Now your .asp and .aspx files will be handled by php.

Copyright ® Rhyous.com – Linking to this page is allowed without permission and as many as ten lines of this page can be used along with this link. Any other use of this page is allowed only by permission of Rhyous.com.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: