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

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?
Yes, probably

See my mono post on Asp.Net here:

Asp.Net web services on FreeBSD and Apache using Mono

Should you migrate your code to php or ruby or another open source language?
Sure, maybe

If you choose not to go with mono 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.

One Comment

  1. haker says:

    please use an English

Leave a Reply

How to post code in comments?