Skip to main content

.htm Extensions for php version

Comments

15 comments

  • cPanelLauren
    Hi @mattc1983
    Last night the upcp job ran on my server which ended up replacing my .htaccess file with the original

    Part of the update to v78 was rebuilding .htaccess files with the correct AddType/handler
    . Is there a better method of rendering my .htm files as php.

    . While it says do not edit above, I cannot find anywhere that I can update the extensions to include .htm. Where can I find this? What updates the .htaccess file with this and what does it use to populate it?

    You should be adding/defining these in cPanel>>Advanced>>Apache Handlers rather than modifying the .htaccess directly.
    0
  • mattc1983
    Hi @mattc1983 Part of the update to v78 was rebuilding .htaccess files with the correct AddType/handler You should be adding/defining these in cPanel>>Advanced>>Apache Handlers rather than modifying the .htaccess directly.

    Hi, I thought I had already done this (image attached). Is this not the correct method? Thanks Matt
    0
  • cPanelLauren
    Hi, I thought I had already done this (image attached). Is this not the correct method? Thanks Matt

    You definitely have if you re-save that does it properly update the .htaccess file and if you run the update again does it overwrite it?
    0
  • ogjuiceloc
    Hi I have cPanel v80.0.11 w/ EasyApache4 and trying to do the same thing. However I don't see cPanel>>Advanced>>Apache Handlers anywhere. I tried to add code lines to Home " Service Configuration " Apache Configuration " Include Editor in all 3 different areas Pre, Post VirtualHost Include + Pre Main Include and it doesn't work. Anytime it sees the first line whether there or directly in the .htaccess, it'll then return a HTTP 500 code for a simple index.htm file. Commenting out the AddType application (I tried AddHandler instead) makes the page render without executing PHP as expected. Also I also looked all over for the correct error_log and can't find the right one when the error is thrown. Where is that? Here is the part that has worked fine for a decade in .htaccess (with ForceType application/x-httpd-php5) before all of this using MultiPHP Manager at /scripts2/multiphp_manager/config: AddType application/x-httpd-ea-php72 .htm .html ForceType application/x-httpd-ea-php72 ForceType application/x-httpd-ea-php72 ForceType application/x-httpd-ea-php72 ForceType application/x-httpd-ea-php72 ForceType application/x-httpd-ea-php72
    I tried the inherit mode last above but had tried the oldest PHPv5.4 in the "Set PHP Version per Domain" and updated the above with "php54" in place of "php72" but same thing and can't modify the auto generated cPanel handler code. Any help to get this working again is appreciated.
    0
  • cPanelLauren
    Hello, If you don't have the apache handlers option I'd suggest contacting your hosting provider as it would seem they've removed this feature from your account. To change the auto Generated handler code you'd need to ensure that the MultiPHP Manager within cPanel reflected the correct PHP version. If you don't have this either it would need to be addressed by your provider.
    0
  • ogjuiceloc
    I got access to cPanel itself vs WHM and was able to add very similarly into the 'User Defined Apache Handlers' section for application/x-httpd-ea-php54 to apply to Extension(s) '.htm .html .php .php5' like so: However, after switching it explicitly in MultiPHP Manager to use PHP v5.4, the auto generated code did not change to include the '.htm .html' extensions and defaulted with [CODE=apacheconf]# php -- BEGIN cPanel-generated handler, do not edit # Set the "ea-php54" package as the default "PHP" programming language. AddHandler application/x-httpd-ea-php54 .php .php5 .phtml # php -- END cPanel-generated handler, do not edit
    So nothing changed why is that? I also tried to revert back to 'inherit' mode and use application/x-httpd-ea-php72 but no difference.
    0
  • cPanelLauren
    When you used the MultiPHP manager to modify the PHP version what did you select? Home Directory or the Site Name? Are there more that one .htaccess files? (I'd check /home/$user and /home/$user/public_html or /home/$user/documentroot if you've selected a different document root
    0
  • Trademarker
    However, after switching it explicitly in MultiPHP Manager to use PHP v5.4, the auto generated code did not change to include the '.htm .html' extensions and defaulted with [CODE=apacheconf]# php -- BEGIN cPanel-generated handler, do not edit # Set the "ea-php54" package as the default "PHP" programming language. AddHandler application/x-httpd-ea-php54 .php .php5 .phtml # php -- END cPanel-generated handler, do not edit
    So nothing changed why is that?

    I have run into the same problem with my server, but found a solution that may work for you. Within cPanel>Advanced>Apache Handlers you need to have a separate defined handler for the .htm .html extensions since the auto generated one never includes those and will rewrite and delete them if added manually. This example is for php v5.4. Handler: application/x-httpd-ea-php54 Extensions: .htm .html This can also be done as a line of code in your .htaccess file which will then show up in the "User Defined Apache Handlers" as an additional rule. AddHandler application/x-httpd-ea-php54 .htm .html
    This rule now survives the rewriting of the auto generated handler and you only need to edit it if you change your php version. I was using this in my .htaccess for ease of changing the version while I was slowly updating my php version making sure things didn't break as I increased the version number. Just uncomment the version you currently have active. #AddHandler application/x-httpd-ea-php56 .htm .html #AddHandler application/x-httpd-ea-php71 .htm .html #AddHandler application/x-httpd-ea-php72 .htm .html #AddHandler application/x-httpd-ea-php73 .htm .html
    Hope this helps.
    0
  • ogjuiceloc
    Thanks a lot for the solution. I did try to add purely the .htm .html extensions only via cPanel>Advanced>Apache Handlers w/o the .php .php5 extensions thinking the same thing since those 2 were part of the auto generated code. However the .htm .html was never added when switching back and forth on PHP versions in the MultiPHP manager. However manually editing the .htaccess file did the trick with AddHandler whereas previously I thought I tried that also but for sure with AddType made the response return an HTTP 500 in conjunction with the auto code so was stuck. I'm glad it somehow works now. @cPanelLauren I'm not sure what you mean by 'Home Directory or the Site Name?' but I can 'Set PHP Version per Domain' for each of my sites (virtual hosts is the right term?) so I changed PHP version to 5.4 and then even 5.5 and back to 5.4 just in case to read the AddHandler new setting for the specific domain having the issue. Each has its own .htaccess file. I did verify it did update the file switching back and forth w/ the respective application/x-httpd-ea-php54 or application/x-httpd-ea-php55 but again, without the *.htm *.html extension I expected to be part of the auto code. Here's the screenshot and I'll test more to make sure my manual addition doesn't get deleted or causes the HTTP 500 again.
    0
  • cPanelLauren
    Hi @ogjuiceloc I see the confusion, thank you so much for including the screenshot. I was indicating using the MultiPHP manager within cPanel - this is what I was suggesting you check, not the global.
    To change the auto Generated handler code you'd need to ensure that the MultiPHP Manager within cPanel reflected the correct PHP version.

    When you switch to inherit from WHM though, it should reflect there. You should also be able to see the .htaccess timestamp be updated when you make this modification through either interface. What are the permissions/ownership of the file? You can get this information by running something like the following in the directory where its located: stat .htaccess
    lsattr .htaccess
    0
  • ogjuiceloc
    Hi @cPanelLauren, I'm still not sure where to go see "using the MultiPHP manager within cPanel". This is all I see when searching with "PHP": The .htaccess files do get updated for any domain that the PHP version is being switched to, even if back to Inherit mode. Are you asking "what are permissions/ownership of the file" for each of these .htaccess files? The answer is that a different user is assigned for each domain. The fact that they are being updated shows there are no permissions issues correct? Doing the 'stat' command shows they are 644: [CODE=bash]Access: (0644/-rw-r--r--) Uid: ( 1004/guidesgv) Gid: ( 1006/guidesgv)
    Using 'lsattr' I get [CODE=bash]-------------e-- /home/guidesgv/public_html/.htaccess
    Do the owners or group need to be more generic and have permissions 664 to allow the auto code actually work with the Apache Handlers entry?
    0
  • cPanelLauren
    Hi @ogjuiceloc If you can't see the MultiPHP manager within cPanel then it would indicate that it's been removed from the package that your account is using. You can add it by going to WHM>>Packages>>Feature Manager -> Manage Feature List -> Edit the feature list associated with that account's package. 644 is pretty standard permissions and the ownership for it looks correct if that's your user for that account. Are you running php-fpm on the account?
    0
  • ogjuiceloc
    Hi @cPanelLauren, I run a VPS from my hosting company so from below it doesn't look like I have the ability to add MultiPHP manager within cPanel? It doesn't appear I'm running PHP-FPM from below though it's somewhat confusing:
    0
  • cPanelLauren
    Hello, That looks like you have access, you'd need to select the feature list that is assigned to the package the account is using then select edit. From what you've shown in that screenshot you're pressing the button next to the Add feature list section. System PHP-FPM is on, when you look at the domain in the MultiPHP Manager do you see the toggle selected to "On" for the domain under php-fpm?
    0
  • ogjuiceloc
    Are you sure that's where I go "add" it? I did click on Edit and here's the list for the 'default' which shows the PHP items checked off already so implies its within WHM and not in cPanel? No, under MultiPHP Manager none of my domains are toggled "On" and in the "Off" state. Should the domain be "On" w/ a lower PHPv5.6 selected to make the auto code work when using via Apache Handlers?
    0

Please sign in to leave a comment.