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
  • 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? Commented Aug 4, 2018 at 6:22

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

this simple solution worked! saved me some frustrations. thanks for the advice, suggestions and valuable responses here!
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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.