0

I try many possibility in .htaccess to make HTML file run PHP code, but it still doesn't run PHP code.

This is what i try to put in .htaccess :

#AddType application/x-httpd-php .html
#AddType application/x-httpd-php5 .html
#AddType x-httpd-php .html
#AddType x-httpd-php5 .html
#AddType php .html
#AddType php5 .html
AddHandler application/x-httpd-php .html
#AddHandler application/x-httpd-php5 .html
#AddHandler x-httpd-php .html
#AddHandler x-httpd-php5 .html
#AddHandler php .html
#AddHandler php5 .html

Any thing else to try on my server to make it runnable ?

HamZa
  • 14,671
  • 11
  • 54
  • 75
Kannika
  • 2,538
  • 2
  • 27
  • 38
  • 1
    HTML run PHP code?!@? PHP can only be run server side, so you need a server to run PHP, not HTML.. The answer is 0 (zero ways) – Ron van der Heijden Jun 18 '13 at 10:03
  • yes, we can make .HTML run as .PHP and i'm sure about that. here is the the same question but i try it and it works in my local server, but it's not working in my real server : http://stackoverflow.com/questions/4687208/using-htaccess-to-make-all-html-pages-to-run-as-php-files – Kannika Jun 18 '13 at 10:05
  • 2
    That is something whole different.... in your question you want HTML to run PHP. in Michael's question he ask for a way to change the .html for the address bar into .php.. So if you want the same, change your question! – Ron van der Heijden Jun 18 '13 at 10:06
  • are you maybe using shorttags? `` instead of ` – x4rf41 Jun 18 '13 at 10:07
  • look at this question, maybe there is something helpful: http://stackoverflow.com/questions/9369781/htaccess-rule-to-parse-php-in-html-files-not-working – x4rf41 Jun 18 '13 at 10:14
  • 1
    @Kannika I would recommend that instead of trying to make .html files executable, figure out some kind of URL routing technique to add html extension to your URLs. That's the right way to go if your aim is to hide the php extension. Making .html files executable can add more security risks to your server. – rineez Jun 18 '13 at 10:21
  • @Kannika If it worked for you in your local server but does not work in the live server, that probably means your live server is not configured to allow adding AddHandler directives. – rineez Jun 18 '13 at 10:26
  • @rineez I think my live server may not allow that too. anyway, i'm working in this path for my client, they already have those files with html and all files are related to the other, so i can't change any extension of they file. that why i need to take the risk with making html run php code. – Kannika Jun 18 '13 at 10:40
  • Your server is already executing .php files right? – rineez Jun 18 '13 at 10:53
  • No, but i have a solution that just use a htaccess to configure with a php file, then in php file include each html to run it to make it run. – Kannika Jun 18 '13 at 14:55
  • Look at my answer to this question http://stackoverflow.com/a/17496769/2171254 – Gjaa Jul 07 '13 at 01:11

0 Answers0