2

Hostgator have changed their server config recently for shared accounts. The result of which is that where html files were previously serving php now they are not. The output includes php tags showing in the source, and of course it is not rendered.

They wont help, telling me its a coding issue. Which I don't believe...

<?php echo 'test'; ?>

doesn't work.

So I can change all the html files and internal links to have php file extensions but this is tedious work. Luckily if I am forced to it is a small site.

However if I add an .htaccess instead with:

AddType application/x-httpd-php .htm .html

this should cut it right?

I then get the request throwing an open file dialog on firefox, and just still not rendering on IE... (I'm getting the error: You have chosen to open...which is: application/x-httpd-php)

Any thoughts appreciated.

5
  • @JonathonReinhart how have you never seen .html files being served as php it is a very common practice, but unnecessary. Commented Nov 8, 2015 at 9:12
  • @TobyAllen I must always manage to find servers that are configured correctly. Commented Nov 8, 2015 at 9:14
  • @JonathonReinhart Just because you havn't heard of something does not mean it is incorrect. This configuration was very standard for quite a long time. You may disagree with it, but it is not wrong. Commented Nov 8, 2015 at 9:15
  • I first set up PHP on Apache on SuSE 7.1. I've never encountered .html or .htm in an AddType statement. Commented Nov 8, 2015 at 9:18
  • Being an old dinosaur myself I think I inherited the idea of php script within the body of html years ago, though clearly I am not a web oriented developer. But frankly I can’t see what's wrong with this, if it works. I would be more than happy @Jonathon if you would tell me why it’s not correct or why its not such a good idea. And what sources would corroborate your opinion. Thanks Commented Nov 8, 2015 at 17:09

1 Answer 1

3

For Hosgator, you should add the following code:

AddHandler application/x-httpd-php5 .html .htm

Notice the the "5" after php.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks I had seen this as an Apache config edit and the AddType as the .htaccess solution, but eitherway this works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.