How can I get to work AddHandler/Action directives in .htaccess for a new file extension?

Avatar
  • updated
  • Answered

.htaccess file contains


  AddType text/html .ahtml
  AddHandler Braces2APL .ahtml  
  Action Braces2APL /home/nars205/public_html/cgi-bin/foo.php
  Options Indexes FollowSymLinks Includes ExecCGI

followed by the original content.

The files foo.ahtml and foo.php are pretty simple.  Invoking foo.ahtml from a browser fails with 404.  Renaming foo.ahtml to foo.html and invoking it from a browser works as expected.  Invoking /cgi-bin/foo.php from a browser works as expected.  The access_log just shows that there was a 404.   The error_log shows no problems. There PHP error log is empty as there are no PHP errors and the PHP executable wasn't invoked.

What am I missing?

Avatar
IMH Support Agent 2
  • Answered
Quote from Sudleyplace

I read the article you referenced, but it did not see how it applied.  The problem as I see it that the Apache Action directive is ignored.

Your suggestion about MIME types, led me to the cPanel Advanced tab where I created a new MIME type of application/x-apl and added a handler of the same name both associated with the extension .ahtml.  I then changed my .htaccess file to

##AddType    application/x-apl        .ahtml
##AddHandler application/x-apl           .ahtml
Action     application/x-apl           /home/nars205/public_html/cgi-bin/foo.php
Options Indexes FollowSymLinks Includes ExecCGI

I commented out the top two lines as (presumably) they duplicate the work of the cPanel.  This allows the .ahtml file to display, but the Action directive does not execute.


Still no joy.

BTW, when I make a change in cPanel such as described above, how soon are those changes reflected in the running Apache Server?  Do I need to restart it, and if so how do I do that?

Thanks for all your help.


The issue here is that you are adding an option that is not being supported in general by the server.  So, in order to make changes to the overall server settings you would need have root access to the server. More specifically, per this document on Braces,

you won't be able to make the Apache Action Handler without access to the Apache configuration file (httpd.conf).  This is a file accessible only with root access on VPS or Dedicated server accounts. On Shared server accounts, it affects all accounts on the server and only the tech support team can make that change. You may submit a ticket to the live technical support team explaining what you're trying to do, and they will be able to tell you if it can be supported.

If you have any further questions or comments, please let us know.

Kindest Regards,

Arnel C.

Avatar
Sudleyplace
Quote from IMH Support Agent 2

Hello Sudleyplace,

Thanks for the question about the Addtype handlers in the .htaccess file.  If you're adding a type, it usually needs to be supported on the server and also by Mime type. They talk about PHP issues with add handlers in this post.

Some of the changes that are mentioned may require some changes at the server level, which we cannot do from the Support Center website.  You would need to submit a ticket to our live technical support team.  


I hope this helps to answer your question.  If you have any further questions or comments, please let us know.


Kindest Regards,

Arnel C.

I read the article you referenced, but it did not see how it applied.  The problem as I see it that the Apache Action directive is ignored.

Your suggestion about MIME types, led me to the cPanel Advanced tab where I created a new MIME type of application/x-apl and added a handler of the same name both associated with the extension .ahtml.  I then changed my .htaccess file to

##AddType    application/x-apl        .ahtml
##AddHandler application/x-apl           .ahtml
Action     application/x-apl           /home/nars205/public_html/cgi-bin/foo.php
Options Indexes FollowSymLinks Includes ExecCGI

I commented out the top two lines as (presumably) they duplicate the work of the cPanel.  This allows the .ahtml file to display, but the Action directive does not execute.


Still no joy.

BTW, when I make a change in cPanel such as described above, how soon are those changes reflected in the running Apache Server?  Do I need to restart it, and if so how do I do that?

Thanks for all your help.


Avatar
IMH Support Agent 2
  • Answered

Hello Sudleyplace,

Thanks for the question about the Addtype handlers in the .htaccess file.  If you're adding a type, it usually needs to be supported on the server and also by Mime type. They talk about PHP issues with add handlers in this post.

Some of the changes that are mentioned may require some changes at the server level, which we cannot do from the Support Center website.  You would need to submit a ticket to our live technical support team.  


I hope this helps to answer your question.  If you have any further questions or comments, please let us know.


Kindest Regards,

Arnel C.