2

We started including some PHP into our web pages, but we wanted to keep our incoming links working. Instead of a bunch of redirects, we simply mapped HTML files to PHP via:

AddType application/x-httpd-php .html

All was well for a few months. Then the the host operators did something to the server (Follow-up: It turned out that the PHP engine was switched), and browsers started downloading the files with the PHP code included (rather than viewing them). They said that we to change our .htaccess file to:

AddType x-httpd-php .html

Is the lack of "application/" newer? Or could they change something again later requiring us to go back?

Is there a more robust way to map .HTML to PHP?

3
  • started downloading the files with the PHP code included sounds like PHP was disabled or removed from the web server Jun 11, 2012 at 23:39
  • @ChristopherWilson Removing "application/" did fix the problem, and .php extensions never broke.
    – sharoz
    Jun 12, 2012 at 0:14
  • Try using mod_rewrite for this and even look at using it to make your URL friendly. This is all I have done in the past when wanting to do things like this.
    – djo
    Jun 12, 2012 at 0:31

1 Answer 1

2

If you are using shared hosting, and you don't control your server, there is always going to be a possibility that the system owner will break something. If you run your own system there is a still a chance something will break, but at least it will break as a result of you doing something. If you setup a good QA infrastructure you can apply updates to a test box before you upgrade the production host allowing you to see what breaks and fix issues before you update the production system.

But yes, it is entirely possible something may change about PHP, or how it is setup on that system in the future breaking that mapping again.

2
  • Thanks for the info! We're a research group hosted by university IT, which is free. But we're considering switching to a private host just for reliability.
    – sharoz
    Jun 12, 2012 at 2:46
  • Well complain to the admins for the university web server. Surely they can setup some kind of automated testing, so when they perform upgrades they get alerted when something breaks.
    – Zoredache
    Jun 12, 2012 at 4:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .