views:

1451

answers:

3

My ISP requires me to put the following in my .htaccess files:

AddType x-mapp-php5 .php

But that breaks my development machine.

I don't really understand what that directive is for, but I'm sick of commenting it out for dev, and uncommenting it whenever I need to upload a new version.

Is there some way of supporting it in dev?

A: 

I'd imagine that this is how you declare the HTTP response Content-Type when Apache returns files ending in .php.

What specifically breaks in your dev environment?

EricLaw -MSFT-
Specifically, my php code is served rather than executed.
Lee Kowalkowski
Lee Kowalkowski
+1  A: 

This merely tells the web server that files with the extension .php are to be handled by the PHP module.

But I would recommend asking web-server related questions on serverfault.com, where your question won't get closed (with the reason belongs on serverfault.com) and where you will receive much better answers than here.

soulmerge
specifically, the PHP5 module
Peter Bailey
Interesting, my httpd.conf has AddType application/x-httpd-php .php - So I assume my php module recognises application/x-httpd-php, yet my ISP's server's php module recognises x-mapp-php5. Perhaps because their default php_module is PHP4.
Lee Kowalkowski
+1  A: 

You could try the <IfModule> Apache directive to distinguish your development machine from the production machine.

E.g. the following would work if you're running PHP as an Apache module, and your ISP runs it as CGI:

<IfModule !mod_php5.c>
AddType x-mapp-php5 .php
</IfModule>

You could also check for the existence of a PHP4 module.

Or you could pass a startup parameter to Apache on your development machine and check for that using <IfDefine>.

mercator
Thanks mercator, That might just work. The ISP offer php4 as default, that's why I have to include that line (to switch to php5). My development server only has php5. So checking for PHP4 sounds like a sensible approach.
Lee Kowalkowski
Excellent, your code snippet worked without modification. As long as my ISP don't change the way they're providing PHP5 unexpectedly, I'll be fine, fingers crossed.
Lee Kowalkowski