Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a virtual server (Windows 2008 R2) with IIS 7.5 and a xxx.php file in one of my websites. This php file contains no php-code and I don't want to install any php-module, I only want the server to return the content of the php file as if it was a normal .html file.

I have a file with the same content named xxx.html in the same directory and that works, but instead of the php file I get a 404 error.

Any ideas?

Update

It's a system that was ported from php to asp.net mvc. Many users have a bookmark to this file and that's why I want to keep it (with the extension). But I found a different way by using using routes in asp.net mvc. Still funny that you cannot configure IIS to simply return php files the same way as html files.

share|improve this question
add comment

4 Answers

up vote 1 down vote accepted

If you don't have a PHP interpreter installed in IIS, it will simply not recognize the file, so it will not be able to make any use of it. If you want IIS to handle a PHP file just like it was a plain text one, you'll need to register its MIME type, so that IIS will know what to do with it.

Please use the instructions provided here: http://technet.microsoft.com/en-us/library/cc725608(v=ws.10).aspx.

The file extension should be, of course, .php; the MIME type should be text/plain.

Please note that doing so will not allow you to use PHP on this server anymore, as it will always handle PHP files like plain text ones, after configuring this setting. If you want to actually use PHP, then you should install and register a PHP interpreter.

share|improve this answer
    
Your answer makes sense. Thank you and thank you to everybody else here who tried to help me. –  Preli Jul 30 '12 at 15:03
add comment

Just rename it to a .htm or .html file? You can't properly serve PHP files without PHP installed... And why is the file a .php file if it doesn't have PHP code in it anyway? What you're asking is daft, you either install and use PHP or you don't.

Edit

Fair enough, it's one of those nuisance things you have to accomplish to accommodate legacy systems. Another way you could do it would be to install PHP then create a small php redirect script, not a perfect solution but a workable one.

share|improve this answer
    
It's a system that was ported from php to asp.net mvc. Many users have a bookmark to this file and that's why I want to keep it (with the extension). But I found a different way by using using routes in asp.net mvc. Still funny that you cannot configure IIS to simply return php files the same way as html files. –  Preli Jul 30 '12 at 8:39
    
You can, see my answer. –  Massimo Jul 30 '12 at 8:43
add comment

Your server must be configured to understand and allow php files.

Please follow this tutorial to enable php: click

If you want to allow specific file extension follow this guide: click

share|improve this answer
    
I don't want to enable php –  Preli Jul 30 '12 at 8:39
    
Follow this tutorial to enable .php file extension to be recognized on your server iis.net/ConfigReference/system.webServer/security/… –  mnmnc Jul 30 '12 at 9:18
add comment

To serve a PHP as plain HTML you just need to map the .php extension to the HTML MIME type. In IIS Manager: MIME Types > Add... Enter the following in the dialog that opens (without the quotes): File name extension: "php", MIME type: "text/html".

You can do this at the Server, Site, or Application level.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.