Go Back   HostGator Peer Support Forums > Public Forums > Suggestions

Notices

Reply
 
Thread Tools
  #1  
Old 02-23-2008, 01:34 AM
whatrevolution's Avatar
whatrevolution whatrevolution is offline
Royal Croc
 
Join Date: Feb 2008
Posts: 710
Thumbs down Please stop suggesting AddHandler ...php .htm .html

Quote:
Originally Posted by GatorAndre View Post
If you added a Mimetype to the system in order to run html files as php scripts (AddType as .htaccess command), you will have to remove it and add an ApacheHandler instead. This is easy to do though. Just log into your control panel, then click on Apache Handlers and add the following:

Extension: html (or htm)
Handler: application/x-httpd-php
And then, during a recent support ticket, a tech does this to my .htaccess "for me".

Code:
AddHandler x-httpd-php .htm .html   
Which was irrelevant, and not worth explaining here.

You can google, "addhandler php", and read the pros and cons on that, but for HostGator, even THAT is not as relevant as this: HostGator's shared/reseller system php.ini allows short-form.

The same people who think typing three fewer letters (i.e.: <? instead of <?php) is awesome could likely think that XHTML and HTML are so similar that this XHTML file can just be .html, or because this was HTML which I just changed to XHTML, it can stay that way so the links to it still work. NOW, guess what happens?

HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
PHP errors on Line 1, since that is not PHP, but it's trying to believe that it is. <?xml didn't stop PHP from thinking that, when I checked.

And in any case, the answer is not to ask the server to check for PHP code in every single .html document. The answer is to change that single .html document to .php, and use a RewriteRule to let the server redirect visitors to the new file.

And about those pros and cons of parsing all .html files for PHP. Shared/Resellers have to worry about their CPU load. Programs which write .html files to disk help to reduce CPU load for serving those documents, only because .html is NOT parsed by PHP.
Reply With Quote
  #2  
Old 02-23-2008, 03:44 AM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: Please stop suggesting AddHandler ...php .htm .html

It's not always bad-- I use that on a lot of sites for various reasons.

I think the best takeaway here is that it's not good in *every* situation, not that it should never be use.

Certainly, I never understood the huge appeal of the short-form tags. Only 3 letters fewer!
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #3  
Old 02-23-2008, 04:20 AM
whatrevolution's Avatar
whatrevolution whatrevolution is offline
Royal Croc
 
Join Date: Feb 2008
Posts: 710
Default Re: Please stop suggesting AddHandler ...php .htm .html

Quote:
Originally Posted by slapshotw View Post
It's not always bad-- I use that on a lot of sites for various reasons.

I think the best takeaway here is that it's not good in *every* situation, not that it should never be use.

Good observations. I had reconsidered the weight of my tone in OP, but decided to let it be. You're right that it is useful, perhaps, when you need a slight bit of PHP in the midst of some existing HTML documents; but that is most appropriate for those of us who really understand what it's doing, and will remember that we did it (because left a note behind in README, perhaps).

Suggesting that Justin Justmakeitwork do that will encourage him to do it on document root, and that is precisely what the previously mentioned HG tech did to mine.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 10:54 PM.