简体   繁体   中英

htaccess AddHandler ***x-httpd-php5x*** and ***application/x-httpd-php5x***

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, eg .myphp

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM