How to run PHP codes in .html files using .htaccess

i have .html file . but i need to run PHP code in .html file (should not be .php).
is ther any way to do this by enything adding in to my .htaccess ?

i have got a answer from How to enable html files to display php code | InMotion Hosting
. so iam tried , but faild. when iam run the .html page . it force to download file…

iam confused. may be @Admin can help me…! [ I think it is the problem with server… ]

See if it helps…

nothing worked here…
this is my website - when visit here…
force me to download file.

?offer=show is a php dipend url ($_GET)

if i visit without this ( )
it work well. i don’t know why ?

Have you tried putting the code in a .php file and just calling it? If I remember correctly, the InfinityFree servers are setup to directly process .php files instead of opening / downloading them.

I know it’s an overkill for 2 lines of code, but I guess it’s worth a try.

i just replaced .php to .html . i need to convert like this . so is there any way to run php in .html ?.

umm! it should be work! but now not for me with infinityfree! i don’t know why!!

@Admin , , i think you can help me about this ! its a problem with the infinity server/hosting

Why don’t you want to run php in .php?

What problem exactly?

It is not even a problem, servers are configured to don’t run php-executor on non php files in order to prevent server overloading and reaching daily limits.


@anon19508339 or @Admin my question Solved , so please close this…

Just hit the checkmark button on one of the replies to mark it as solved, it will also be closed in 15 days automatically.

Add this to your .htaccess file:

AddType application/x-httpd-php .html

I know this works as I use it on these servers.


mm! working well!

I personally don’t recommend it. Making server to run php in html files reaches limits faster. That’s why it’s recommended to use html for static websites since there’s no php executed in non php files by default.


I agree with this.

@AdYouWebs It’s quite illogical what your asking, why don’t you just rename your file to .php? There’s no harm in doing it. .php is made to execute PHP scripts and .html files are made for HTML codes, it’s a fact.

I don’t know if that .htaccess code is safe or not, but like most things, it probably has a side effect or a downside.


Don’t werry! i got the answer

yes Good question! but there is some issue on my pages, that’s why i don’t change extenstion!

great! thanks for your information

But i temperary run like this!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.