Execute .html as .php
I have a bunch of folders with .html files that start with a single line of php code. They used to get executed, but now -after moving to another server- they don't. Also I used to run php5 as DSO now I do as CGI.
pre_virtualhost_global.conf:
My .htaccess (that used to work):
I've moved php_value to php.ini so that one is no longer there. Now I've tried: AddType application/x-httpd-php .htm .html RewriteEngine on RewriteRule \.(html|htm)$ - [T=application/x-httpd-php5] AddHandler application/x-httpd-php5 .html AddHandler x-httpd-php5-6 .html AddType application/x-httpd-ea-php70 .html AddHandler application/x-httpd-php .html Options +ExecCGI AddType application/x-httpd-php .php .html AddHandler x-httpd-php5 .php .html Some of them even caused the browser to download the file. I'm not sure if it doen't work because I've changed PHP to DSO or if it is because something else has changed.... any ideas are welcome.
Options All
AllowOverride All
My .htaccess (that used to work):
RewriteEngine on
AddHandler application/x-httpd-php .html .htm .html5
php_value auto_prepend_file /home/domain/domain.net/checkdomain.php
DirectoryIndex index.php index.html
Options -Indexes
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www.domain..*$ [NC]
RewriteCond $0 !^www/
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ www/$0 [NC,L]
I've moved php_value to php.ini so that one is no longer there. Now I've tried: AddType application/x-httpd-php .htm .html RewriteEngine on RewriteRule \.(html|htm)$ - [T=application/x-httpd-php5] AddHandler application/x-httpd-php5 .html AddHandler x-httpd-php5-6 .html AddType application/x-httpd-ea-php70 .html AddHandler application/x-httpd-php .html Options +ExecCGI AddType application/x-httpd-php .php .html AddHandler x-httpd-php5 .php .html Some of them even caused the browser to download the file. I'm not sure if it doen't work because I've changed PHP to DSO or if it is because something else has changed.... any ideas are welcome.
-
SOLUTION: The correct line (for EasyApache 4) is AddHandler application/x-httpd-ea-php56 .html0 -
Would encourage against this. If you move the account to a different server, perhaps one that doesn't use cPanel and you forget that you had this here, you run a real risk of exposing your PHP code to regular website visitors. If that PHP code has private and confidential information, then that could be a disaster. That's kind of why they created the .php file extension. Files with a .php extension are expected to be parsed through a PHP interpreter. Files with a .html extension are not. Perhaps you have a specific reason for needing this. And I'm not saying that it is inherently wrong. But I am detailing why I think it is a bad idea. 0 -
I'd normally agree with you but this specific case requires (automatically generated) .html files to be parsed as php to auto prepend code. 0 -
Hi @PatrickVeenstra I'm glad to see you found the solution for your issue. Thank you for posting the solution that worked for you. Thanks! 0
Please sign in to leave a comment.
Comments
4 comments