user10179042
user10179042

Reputation: 37

how to parse php file inside of html file

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)

Upvotes: 1

Views: 2228

Answers (2)

user2338456
user2338456

Reputation: 520

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

Upvotes: 1

Mahdi Mirhendi
Mahdi Mirhendi

Reputation: 452

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

Upvotes: 0

Related Questions