4

What is the difference between x-httpd-php5x and application/x-httpd-php5x

I'v been using application/x-httpd-php for years with my web hosting (Linux) until they upgrade PHP to version>=5.2. Now I have to use x-httpd-php5x on web hosting which does not work on localhost (Windows).

So everytime I made some changes to the .htaccess, I have to change the AddHandler as well while uploading to web hosting.

Is there a cross-platform AddHandler to parse files as PHP?

edit

.php can always work, with/without specifing in .htaccess. but not custom extesions, e.g. .myphp

user1643156
  • 4,407
  • 10
  • 36
  • 59
  • 1
    That's a directive that usually belongs to `httpd.conf`. Try taking it out of your `.htaccess` and see if your scripts will still be excuted. Setting that directive in `.htaccess` is usually done, when you don't have access to your server's config, which is mostly a case at some webhosting companies. – Havelock Oct 18 '12 at 13:30
  • "What is the difference?" `application/x-httpd-php` is a valid [internet media type](http://en.wikipedia.org/wiki/Internet_media_type), `x-httpd-php5x` isn't. – feeela Oct 18 '12 at 13:40
  • @feeela 5x = 52 or 53. but `only x-httpd-php52` or `x-httpd-php53` works on my web hosting. – user1643156 Oct 18 '12 at 13:43
  • 1
    Out of curiousity, why not use Linux as a development environment, and dual-boot between that and Windows? Alternatively, if you use something like git for version control, I think git-ftp by resmo allows for specific files to not be synched. That way, you could use the `x-httpd-php5x` on the server, but use `application/x-httpd-php5x` on localhost – Chris Forrence Oct 18 '12 at 13:48
  • @GlaciesofPacis ahha...I forgot to switch to linux...wait...do I have Linux installed? :) Thanks for the tip, but I'm not familar with Linux, and I believe there are a lot of people out there using a Linux hosting while developing on Windows locally. – user1643156 Oct 18 '12 at 13:55
  • @user1643156 - That's totally fine! Then you might want to look at using git + git-ftp to synchronize files, but be able to ignore certain files (so as to not overwrite your web hosting's .htaccess with your local .htaccess) – Chris Forrence Oct 18 '12 at 13:59

1 Answers1

2

The media type application/x-httpd-php5 was introduced specifically for PHP 5.0, application/x-httpd-php51 for PHP 5.1, application/x-httpd-php52 for PHP 5.2, etc...

In other words: the difference between them is to which version of PHP they are referring.

application/x-httpd-php is kind of obsolete, because it doesn't really refer to any version. This was fine in the early days of PHP, but as the number of versions grew, there was need for something more specific.
Most webhosts nowadays support multiple versions of PHP, and their webservers use the media types to pass the correct files to the correct PHP interpreters.

If your local development machine has PHP 5.1 or below installed, it's probably the reason why it doesn't support media types for PHP 5.2 and up.

A bit off-topic: If you have PHP 5.2 or below installed, I would advise you to upgrade to PHP 5.3 or up. At the time of this writing all versions below 5.3 are deprecated.

Jasper N. Brouwer
  • 21,517
  • 4
  • 52
  • 76