can't for the life of me work out why this isn't working - on a dreamhost server, I've created an htaccess file and added AddHandler php5-cgi .html .htm to allow php in html files, as per the dreamhost docs. On an identical dreamhost package, I've done the same thing for another site and it worked perfectly, but in this case it just won't parse the php! Is there anything I could have missed here which could be causing the problem? The htaccess is in the web root and isn't being overridden by anything else.
Try this
AddType application/x-httpd-php .html .htm
The above setting will work if the apache is picking php as a module.
AddHandler application/x-httpd-php .html .htm
or
AddHandler application/x-httpd-php5 .html .htm
above will work if apache is executing php as CGI?
there is no harm i would say to put both of the above conditions together but try one over other and see if it work for you.
read more here in this article I wrote.
Is your server using suPHP rather than mod_php or plain php-cgi?
Try using
AddHandler x-httpd-php .html .htm
or
AddType application/x-httpd-php .html .htm
instead.
Postscript
Shared Hosting services use UID based separation on individual accounts from each others. Most use suPHP, but some use suEXEC. They will use one of these. Both act as a su wrapper around php-cgi so you can't tell from the phpinfo()as its PHP scripting engine as this will report Server API CGI/FastCGI in both cases. For CGI initiated scripts, phpinfo doesn't report on the Apache config. You need either to look at your hosting provider's FAQ or possibly try:
<?php
header( "Content-Type: text/plain");
echo system('grep -iR LoadModule /etc/httpd /etc/apache2');
The hosting provider's support forums / FAQ might give specific configuration advice here. Have you tried them?
I've got the same problem as you but I just put this AddType php .html .htm to my .htaccess, it's working.
For me it is working for only like this:
AddHandler php-cgi .php .htm
Related
My Webhoster doesnt accept PHP Version change for single domains. The PHP version (7.3) work only for all domains on my webhost account. But for one domain, i need 5.3 and i cant configure it.
I can made extensions in "Apache-Configuration" > "for single Domains" but i dont know what command code i need here. I tried second way, in htaccess to force it via "AddHandler..." "AddType application/x-httpd-php53 .php" but the browser open/download a file instead.
can it be that my webhost does not allow simultaneous use of different versions? is there any possibility ?
Try all solution on stackoverflow i found. (My Site is a index.php)
AddType application/x-httpd-php53 .php
AddHandler application/x-httpd-php53 .php
AddHandler x-httpd-php5-3 .php
No PHP changing. Instead, browser want downloading a file.
This is what I use, for php 7.3:
#AddType application/x-httpd-ea-php73 .php .php7 .phtml .html .htm
#AddHandler application/x-httpd-php .htm .html
You may want to consider switching your webhost... the standard version of cPanel allows for multiple PHP installations, configurable per domain.
My apache runs php files with or without .php extension, How can I disable this and force apache to run php files only with .php extension. I don't want to use .htaccess, this might be an apache config. does anyone know how to disable this option?
Thanks for the answer but using Addtype as you mentioned did not ever work for me, all by itself, even in PHP 5..
Here's what I've tried that DOESN'T work with this version of PHP:
Options +ExecCGI
AddType application/x-httpd-php .php .nusuffix
AddHandler x-httpd-php5 .php .nusuffix
This worked for PHP 5. Now, does not.
This is for a hosted account, so I must do this via .haccess.
You can check your httpd.conf what extensions are configured, it need need to be following. if there is change in your file you can change it to following and restart the apache
AddType application/x-httpd-php .php
more details : https://wiki.archlinux.org/index.php/Apache_HTTP_Server
please add if anything is missing
I have few files whose extension is htm that i want to run as php using htaccess code
this is the htaccess code that i am using
AddHandler application/x-httpd-php5 .htm .php .html
this code work fine but now i change my hosting server in that this code not working.
i tried all these code but no one work
AddHandler application/x-httpd-php .htm .php .html
AddType application/x-httpd-php .html .htm
AddType application/x-httpd-php5 .html .htm
my new server says
cPanel Linux Hosting packages only support the SymLinksIfOwnerMatch option in the .htaccess file.
Please point me in right direction how can i run htm file as php on my server
I'm afraid it's a no-go then... If your hosting blocks the appropriate directives in your .htaccess, your only way to go would be to either blackmail or hack the provider, or change the extension from .htm to .php. As this is really a server-administration thing, and if the server administrator doesn't allow you, there is no way you can go around it...
A hacky solution would be to use rewrites to route .htm to .php files. But still then you'd need to rename your files from .htm to .php. This could be a solution if you're app routing isn't setup dynamically and your main concern is that the url's should not be changed. Although changed url's can be caught with 301 redirects.
I've read everything here and tried almost all the suggestions, nothing is helping.
I've got several static .htm pages that all call common headers & footers via a php include:
<?php include('inc_logo_nav.htm');?>
So I just moved to a new server with all kinds of higher level security and nothing we have tried helps.. the system refuses to allow these include calls unless I change the file extension to .php
On the old server I was using in my .htaccess:
AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm
But on this new box I had to comment out those lines to get the pages to even come up. The tech guy is stumped too..
back to suphp & seuexec but no nginx
and that didnt help either...
cPanel Server running: CENTOS 6.5 x86_64 vmware – WHM 11.40.
I'm already suffering from loss of traffic, changing all the pages to .php after 20+ years is going to kill the site... Can anyone help here??
Thanks
Have you tried these in your .htaccess?
AddHandler x-mapp-php5 .html .htm
AddHandler x-mapp-php6 .html .htm
I needed them on a server hosted by 1&1 to cause HTML files to be parsed as PHP.
I'm running XAMPP.
Is there a line I can add to .htaccess or http.conf to make ASP be parsed and handled as PHP pages?
I had it setup before but can't remember how to do it. What I've tried so far hasn't worked.
Edit: None of these solutions are working, I've tried everything.
If none of the solution above is ok with you, check your Server API with phpinfo(); method.
If Server API is CGI or FAST CGI change it to Apache 2.0 Handler.You can do it using Plesk Panel or CPanel.
Another option is not to change Server API but .htaccess or httpd.conf : http://avinashsing.sunkur.com/2012/04/19/how-to-map-another-file-extension-to-the-php-parser-through-htaccess/.
But I have solved my problem with the first one.
Maybe try this:
AddHandler php5-script .php .asp .aspx .ascx .ashx .asmx
AddType text/html .php .asp .aspx .ascx .ashx .asmx
Add this to your httpd.conf
AddType application/x-httpd-php .asp .aspx .ascx .ashx
Try adding this line to .htaccess;
AddHandler application/x-httpd-php .asp
Apparently it is not as efficient as adding the equivalent to http.conf but it works even when you don't have access to http.conf.
Adding this line in .htaccess enabled me to execute PHP code written in .asp pages:
AddHandler php5-script .php .asp
Apache does not have a module for ASP processing. You have to use IIS for that. Modern IIS can run PHP so you may do it the other way around, use IIS and plug PHP into it.