Jump to content

Interpreting HTML as PHP files Using .htaccess


iwato

Recommended Posts

The following code was inserted into the root folder of my www.grammarcaptive.com site in the form of an .htaccess control file.  It was also inserted into my test server in an identical location.  Although it appears to work well on the remote server, it fails on the local test server.  Only the paths leading up to the sites' root folders appear to be different.  

THE CODE

<IfModule mime_module>
		AddType application/x-httpd-ea-php56 .php .html
</IfModule>

REMOTE SERVER PATH

public_html/grammarcaptive.com/.htaccess

LOCAL TEST SERVER PATH

../../Sites/grammarcaptive.com/.htaccess

QUESTION:  Could the above path differences be at cause, or  might there be an APACHE directive of some sort getting in the way?  If so, what directive is it likely to be, and where should I look for it?

Link to comment
Share on other sites

Apache will look for and process .htaccess files in any directory inside the path that was requested.  So as long as that file is in the path that was requested then it will be processed.  It might not work on your local server because it might not have application/x-httpd-ea-php56 as a recognized type.  That works on your remote server because that looks like it's a cPanel server with multiple versions of PHP installed, and you have PHP 5.6 enabled for your account.

Link to comment
Share on other sites

So, if I change the phrase

AddType application/x-httpd-ea-php56 .php .html

to read

AddType application/x-httpd-ea-php55 .php .html

to better reflect my test server's version of PHP -- namely,  PHP 5.5.38 --, then there is some chance that I will be able to achieve a result similar to that of my web host server.

Roddy

Link to comment
Share on other sites

Well, if you're saying that the chance is greater than 0, then I guess I would agree that would have to be the case, but I wouldn't expect that to work.  I believe the ea in that mime type stands for EasyApache, which is how WHM/cPanel servers update and configure Apache and PHP.  If you aren't using EasyApache, then I doubt your server is going to have that particular mime type set up for it.  But, like I said, I would have to admit that the probability of it working is at least greater than 0.

Instead, try to figure out, from documentation or program settings, what mime type your server is actually using for PHP.  That will get you a lot closer than a guess.

  • Thanks 1
Link to comment
Share on other sites

OK.  I have changed the directives setting from the above to the following:

AddType text/html .php
AddHandler application/x-httpd-php55 .html .htm

but still the desired effect is not achieved, but for the fact that my Javascript fails.  

Indeed, the purpose of  the PHP script is to signal to Javascript to ignore a specific Javascript procedure, not Javascript in its entirety.

Link to comment
Share on other sites

Thank you for your help.  I was finally able to resolve the issue by adding the following code to my httpd.conf file.

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

Roddy

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...