1

Could someone help me configure my httpd.conf server file so I can execute simple php code run as .html file?

The browser outputs nothing or is just blank. (ex. )

php version - 7.2.8 server version - Apache/2.4.34 (Fedora)

  • 1
    Normally the browser can interpret html and your server can interpret PHP. So I don't undertand the question. Perhaps show an example of what you need to do. Is it how to configure Apache for PHP? – bcperth Aug 04 '18 at 06:22

2 Answers2

1

Create .htaccess file in your project directory and use below code:

RewriteEngine On
RewriteRule index.html index.php

replace index with your script file name

user3782114
  • 542
  • 2
  • 7
  • 22
  • this simple solution worked! saved me some frustrations. thanks for the advice, suggestions and valuable responses here! – user10179042 Aug 04 '18 at 19:37
0

you should save your html file with php Format or Using .htaccess to make all .html pages to run as .php files :
First way:

file.html most convert to file.php

you most Run your web service and then open your file with logical address http://localhost/file.php

Secund Way: Create a .htaccess file at the root of your website and add this line:

[Apache2 @ Ubuntu/Debian: use this directive]

AddType application/x-httpd-php .html .htm

Or, from comment below:

AddType application/x-httpd-php5 .html .htm

If your are running PHP as CGI (probably not the case), you should write instead:

AddHandler application/x-httpd-php .html .htm 

Using .htaccess to make all .html pages to run as .php files

Mahdi Mirhendi
  • 363
  • 1
  • 4
  • 14