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

后端 未结 12 2082
栀梦
栀梦 2020-11-21 22:05

I can\'t use PHP in my HTML pages. For example, index.html. I\'ve tried using both:

 

and



        
12条回答
  •  感情败类
    2020-11-21 22:56

    I think writing PHP into an .html file is confusing and anti-natural. Why would you do that??

    Anyway, if what you want is to execute PHP files and show them as .html in the address bar, an easiest solution would be using .php as normal, and write a rule in your .htaccess like this:

    RewriteRule ^([^.]+)\.html$ $1.php [L]
    

提交回复
热议问题