0

everybody! I am going to include php code in .html file... I have read the instruction here: include php script inside HTML But after opening my html file on the server, it does not open the html file, instead it downloads the html file. In online server it downloads the file, but in local machine it does not run, but the html file opens.

What is the problem? And how to fix it?

Thank you!

Community
  • 1
  • 1
Saidmamad
  • 55
  • 1
  • 12
  • 1
    You can not save PHP code into .html file if you want to run PHP code than file should be saved with .php extestion. With your reference link please look at http://www.askapache.com/htaccess/htaccess.html where AddType Forces file for Save As. – Haresh Kumar Jun 20 '16 at 09:44
  • 1
    If you want to display your extension as .html instead .php into address bar you can use apache rewrite rules for that purpose. – Haresh Kumar Jun 20 '16 at 09:46
  • Thank you, @HareshKumar for you reply! I wondered how they could do it in this post: http://stackoverflow.com/questions/6416418/include-php-script-inside-html )) Displaying php file as .html is also an alternative variant. Could you please tell me how to do that? – Saidmamad Jun 20 '16 at 10:06
  • For URL rewriting you can follow https://alexcican.com/post/how-to-remove-php-html-htm-extensions-with-htaccess/ – Haresh Kumar Jun 20 '16 at 10:13
  • 1
    Possible duplicate of [How do I add PHP code/file to HTML(.html) files?](http://stackoverflow.com/questions/11312316/how-do-i-add-php-code-file-to-html-html-files) – Elshan Jun 20 '16 at 10:25

1 Answers1

1

This is duplicate questions. Please refer this link. I hope Its will help you.

How do I add PHP code/file to HTML(.html) files?

Thank You!

Community
  • 1
  • 1
Ragu Natarajan
  • 689
  • 3
  • 15