I've swapped from ASP.NET to .PHP for cost reasons. As such, I want the people to be redirected from .ASPX to its equivalent .PHP. If I create the .aspx with HTML, the file is simply displayed in the browser as text and not treated as text. How can I make the browser treat .aspx as HTML or is there another way to make APACHE redirect from aspx to its equivalent?
first, the browser does not care about the extension of the file name.
if in the response HTTP header you specify the content as
text/html the browser will render the response as html.
if you specify the response as
text/plain the browser will just print the text.
what you should do is 2 things:
YardenST is completely right it is your HTTP headers that are not telling your browser that the page is HTML and not a txt file.
But keep in mind what you are doing with .aspx is probably not the smartest thing in the world. Most web developers go out of their way to mask all file extensions (jsp, asp, shtml, php). If you are going to write rewrite rules, why not create one that actually hides the file extension so that: Default.aspx becomes Default. If you are trying to pretend that apache or whatever is serving your PHP files is IIS, dont. First its extremly easy to tell what server you are running on, and even if you changed the server headrers, its not worth the trouble.
Maybe you should just rename all your files to .php (so that if the application needs to be re-coded or edited your editor actually does the syntax highlighting for php and there is no confusion among devs), and then hide the .php extension, or write a rewrite rule that requests to .aspx are forwarded to .php.
I just had to do this today, I approached it the same way you would run php inside of html files. In my case I'm not worried about file extensions showing in the address bar, it's a copy of a client's Website he no longer has access to.
AddType application/x-httpd-php .aspx AddHandler application/x-httpd-php .aspx
I hope that helps some.